improve performances by not shuffling vectors
in ./bins/inbreeding/
, this MR does
- refactor the "list item drawing" from
environment.rs
andstrategy.rs
into thedraw_unique_elements
function of newrandom.rs
module - use a
HashSet
to draw unique indices in the slice of "things" to draw from and then extracts the items corresponding to these indices
results
use ./bins/inbreeding
use std bench
const PRNG_SEED = 0
const OPTS = {
nb_bytes: (10 * 1_024),
k: 10,
n: 20,
nb_measurements: 100,
nb_scenarii: 10,
measurement_schedule: 1,
measurement_schedule_start: 2_000,
max_t: 2_000,
strategies: [ "single:5" ],
environment: null,
}
def run [rev: string] {
git co $rev
inbreeding build
let a = bench --rounds 5 {
inbreeding run --options ($OPTS | update environment "fixed:0") --prng-seed $PRNG_SEED
}
let b = bench --rounds 5 {
inbreeding run --options ($OPTS | update environment "fixed:1") --prng-seed $PRNG_SEED
}
{
0: $a,
1: $b,
}
}
let main = run a29b511
let mr = run fix-shuffle
let table = [
[env, main, mr, improvement];
["fixed:0", $main."0".mean, $mr."0".mean, (($main."0".mean - $mr."0".mean) / $main."0".mean * 100)],
["fixed:1", $main."1".mean, $mr."1".mean, (($main."1".mean - $mr."1".mean) / $main."1".mean * 100)],
]
$table | to md --pretty
env | main | mr | improvement |
---|---|---|---|
fixed:0 | 8sec 504ms 794µs 784ns | 6sec 353ms 206µs 645ns | 25.298530930431912 |
fixed:1 | 727ms 648µs 292ns | 639ms 443µs 782ns | 12.12186037811795 |
the improvement is quite nice, even though not huge, but the code is cleaner anyways
Merge request reports
Activity
Filter activity
mentioned in commit 47ba0de8
mentioned in merge request !127 (merged)
mentioned in commit e5311d6c
Please register or sign in to reply