-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running microbenchmarks on supported bitgenerators
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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,36 @@ | ||
open Bitgen | ||
|
||
module type S = sig | ||
type t | ||
val next_uint64 : t -> Stdint.uint64 * t | ||
val initialize : SeedSequence.t -> t | ||
end | ||
|
||
|
||
let make_bits (module M : S) = | ||
let ss = SeedSequence.initialize [Stdint.Uint128.of_int 123456789] in | ||
let t = ref (M.initialize ss) in | ||
let bits () = match M.next_uint64 !t with | ||
| (u, t') -> t := t'; u | ||
in | ||
bits | ||
|
||
|
||
let pairs = [ | ||
"PCG64", (module PCG64: S); | ||
"SFC64", (module SFC64: S); | ||
"Xoshiro256", (module Xoshiro256: S); | ||
"Philox64", (module Philox64: S); | ||
] | ||
|
||
|
||
let make_fn (name, m) = | ||
Core_bench.Bench.Test.create ~name:(name ^ ".next_uint64") (make_bits m) | ||
|
||
|
||
let () = | ||
Stdlib.Random.init 123456789; | ||
[Core_bench.Bench.Test.create ~name:"Stdlib.Random.bits64" (fun () -> Stdlib.Random.int64 Int64.max_int)] @ | ||
List.map make_fn pairs | ||
|> Core_bench.Bench.make_command | ||
|> Command_unix.run |
This file contains 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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
(executable | ||
(public_name crush) | ||
(name crush) | ||
(modules crush) | ||
(ocamlopt_flags (:standard -O3)) | ||
(libraries bitgenerators testu01)) | ||
|
||
|
||
(executable | ||
(public_name bench) | ||
(modules bench) | ||
(ocamlopt_flags (:standard -O3)) | ||
(libraries bitgenerators core_bench core_unix.command_unix)) |