-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Factor: base benchmarking for single/multiple u64, u128, and >u128 #9182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
365ba78
factor: use num_prime's u64 and u128 factorization methods to speed u…
asder8215 d10f756
fix cspell issue (renamed function) and changed parsing of u128 digit…
asder8215 28fafb9
rollback converting from big_uint to u128
asder8215 d7f5b12
factor: base benchmarking for single/multiple u64, u128, and >u128
asder8215 5ada98b
reset factor.rs to original branch code and added uu_factor to benchm…
asder8215 e408039
changed benchmarking to use a smaller range of u64/u128/biguint integers
asder8215 51553a4
reduced range for big_uint to 25 numbers only
asder8215 5fb1a8f
reduced factor multiple_big_uint to a range of 3
asder8215 b492abd
lowered divan bench samples and refactored benchmark code to use args…
asder8215 9e788c7
factor/bench: big_uint only benchmarks numbers that num_prime can fac…
asder8215 d977e29
factor/bench: reduced range on u64 and u128 benchmarking and remove s…
asder8215 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // This file is part of the uutils coreutils package. | ||
| // | ||
| // For the full copyright and license information, please view the LICENSE | ||
| // file that was distributed with this source code. | ||
|
|
||
| use divan::{Bencher, black_box}; | ||
| use uu_factor::uumain; | ||
| use uucore::benchmark::run_util_function; | ||
|
|
||
| /// Benchmark one u64 digit | ||
| #[divan::bench] | ||
| fn factor_single_u64(bencher: Bencher) { | ||
| bencher | ||
| .with_inputs(|| 1000000_u64) | ||
| .bench_values(|single_u64| { | ||
| black_box(run_util_function(uumain, &[&single_u64.to_string()])); | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmark multiple u64 digits | ||
| #[divan::bench] | ||
| fn factor_multiple_u64s(bencher: Bencher) { | ||
| bencher | ||
| .with_inputs(|| (2_u64, 1000000_u64)) | ||
| .bench_values(|(start_u64, end_u64)| { | ||
| for u64_digit in start_u64..=end_u64 { | ||
| black_box(run_util_function(uumain, &[&u64_digit.to_string()])); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmark one u128 digit | ||
| #[divan::bench] | ||
| fn factor_single_u128(bencher: Bencher) { | ||
| bencher | ||
| .with_inputs(|| 18446744073709551616_u128) | ||
| .bench_values(|single_u128| { | ||
| black_box(run_util_function(uumain, &[&single_u128.to_string()])); | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmark multiple u128 digits | ||
| #[divan::bench] | ||
| fn factor_multiple_u128s(bencher: Bencher) { | ||
| bencher | ||
| .with_inputs(|| { | ||
| // this is a range of 1 million different u128 integers | ||
| (18446744073709551616_u128, 18446744073710551616_u128) | ||
| }) | ||
| .bench_values(|(start_u128, end_u128)| { | ||
| for u128_digit in start_u128..=end_u128 { | ||
| black_box(run_util_function(uumain, &[&u128_digit.to_string()])); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmark single > u128::MAX digits | ||
| #[divan::bench] | ||
| fn factor_single_big_uint(bencher: Bencher) { | ||
| // max u128 value is 340_282_366_920_938_463_463_374_607_431_768_211_455 | ||
| bencher | ||
| .with_inputs(|| "340_282_366_920_938_463_463_374_607_431_768_211_456") | ||
| .bench_values(|single_big_uint| { | ||
| black_box(run_util_function(uumain, &[single_big_uint])); | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmark multiple > u128::MAX digits | ||
| #[divan::bench] | ||
| fn factor_multiple_big_uint(bencher: Bencher) { | ||
| // max u128 value is 340_282_366_920_938_463_463_374_607_431_768_211_455 | ||
| bencher | ||
| .with_inputs(|| (768_211_456_u64, 769_211_456_u64)) | ||
| .bench_values(|(start_big_uint, end_big_uint)| { | ||
| for digit in start_big_uint..=end_big_uint { | ||
| let big_uint_str = format!("340282366920938463463374607431768211456{digit}"); | ||
| black_box(run_util_function(uumain, &[&big_uint_str])); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| fn main() { | ||
| divan::main(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.