Skip to content

Commit 29ec8f3

Browse files
authored
Merge pull request #9311 from uutils/sylvestre-patch-2
Remove high variance benchmark functions
2 parents 7478749 + c175983 commit 29ec8f3

File tree

1 file changed

+0
-89
lines changed

1 file changed

+0
-89
lines changed

src/uu/factor/benches/factor_bench.rs

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -22,95 +22,6 @@ fn factor_multiple_u64s(bencher: Bencher, start_num: u64) {
2222
});
2323
}
2424

25-
/* Too much variance
26-
/// Benchmark multiple u128 digits
27-
#[divan::bench(args = [(18446744073709551616)])]
28-
fn factor_multiple_u128s(bencher: Bencher, start_num: u128) {
29-
bencher
30-
.with_inputs(|| {
31-
// this is a range of 1000 different u128 integers
32-
(start_num, start_num + 1000)
33-
})
34-
.bench_values(|(start_u128, end_u128)| {
35-
for u128_digit in start_u128..=end_u128 {
36-
black_box(run_util_function(uumain, &[&u128_digit.to_string()]));
37-
}
38-
});
39-
}
40-
*/
41-
42-
/* Too much variance
43-
/// Benchmark multiple > u128::MAX digits
44-
#[divan::bench]
45-
fn factor_multiple_big_uint(bencher: Bencher) {
46-
// max u128 value is 340_282_366_920_938_463_463_374_607_431_768_211_455
47-
bencher
48-
// this is a range of 3 different BigUints. The range is small due to
49-
// some BigUints being unable to be factorized into prime numbers properly
50-
.with_inputs(|| (768_211_459_u64, 768_211_461_u64))
51-
.bench_values(|(start_big_uint, end_big_uint)| {
52-
for digit in start_big_uint..=end_big_uint {
53-
let big_uint_str = format!("340282366920938463463374607431768211456{digit}");
54-
black_box(run_util_function(uumain, &[&big_uint_str]));
55-
}
56-
});
57-
}
58-
*/
59-
60-
#[divan::bench()]
61-
fn factor_table(bencher: Bencher) {
62-
#[cfg(target_os = "linux")]
63-
check_personality();
64-
65-
const INPUT_SIZE: usize = 128;
66-
67-
let inputs = {
68-
// Deterministic RNG; use an explicitly-named RNG to guarantee stability
69-
use rand::{RngCore, SeedableRng};
70-
const SEED: u64 = 0xdead_bebe_ea75_cafe; // spell-checker:disable-line
71-
let mut rng = rand::rngs::StdRng::seed_from_u64(SEED);
72-
73-
std::iter::repeat_with(move || {
74-
let mut array = [0u64; INPUT_SIZE];
75-
for item in &mut array {
76-
*item = rng.next_u64();
77-
}
78-
array
79-
})
80-
.take(10)
81-
.collect::<Vec<_>>()
82-
};
83-
84-
bencher.bench(|| {
85-
for a in &inputs {
86-
for n in a {
87-
divan::black_box(num_prime::nt_funcs::factors(*n, None));
88-
}
89-
}
90-
});
91-
}
92-
93-
#[cfg(target_os = "linux")]
94-
fn check_personality() {
95-
use std::fs;
96-
const ADDR_NO_RANDOMIZE: u64 = 0x0040000;
97-
const PERSONALITY_PATH: &str = "/proc/self/personality";
98-
99-
let p_string = fs::read_to_string(PERSONALITY_PATH)
100-
.unwrap_or_else(|_| panic!("Couldn't read '{PERSONALITY_PATH}'"))
101-
.strip_suffix('\n')
102-
.unwrap()
103-
.to_owned();
104-
105-
let personality = u64::from_str_radix(&p_string, 16)
106-
.unwrap_or_else(|_| panic!("Expected a hex value for personality, got '{p_string:?}'"));
107-
if personality & ADDR_NO_RANDOMIZE == 0 {
108-
eprintln!(
109-
"WARNING: Benchmarking with ASLR enabled (personality is {personality:x}), results might not be reproducible."
110-
);
111-
}
112-
}
113-
11425
fn main() {
11526
divan::main();
11627
}

0 commit comments

Comments
 (0)