package core_bench
Benchmarking library
Install
Dune Dependency
Authors
Maintainers
Sources
core_bench-v0.14.0.tar.gz
sha256=798555665726d5e4a620720be3c1b7ea4ce7995bf8880e0acbecc1309061d7b2
md5=96c9241f978acbc3a6817b20b281996f
doc/src/core_bench.inline_benchmarks/common.ml.html
Source file common.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
open Core open Core_bench module Entry = Ppx_bench_lib.Benchmark_accumulator.Entry let make_benchmark_name entry = let module_name = match Entry.get_module_name_opt entry with | Some s -> ":" ^ s | None -> "" in let bench_module_name = match entry.Entry.bench_module_name with | Some s -> ":" ^ s | None -> "" in String.concat [ "[" ; entry.Entry.filename ; module_name ; bench_module_name ; "] " ; entry.Entry.name ] (* Code for filtering the out the benchmarks to run *) let entry_to_bench_test entry ~key = let open Entry in let name = make_benchmark_name entry in let test_name = entry.name in let file_name = entry.filename in let module_name = entry.bench_module_name in match entry.Entry.test_spec with | Regular_thunk f -> Bench.Test.create_with_initialization ~name ~test_name ~file_name ?module_name ~key f | Indexed_thunk { arg_values; thunk; _ } -> Bench.Test.create_indexed ~name ~test_name ~file_name ?module_name ~args:arg_values ~key (fun len -> Staged.stage (thunk len)) let pattern_to_predicate s = let regexp = Re.Perl.compile_pat s in (fun entry -> let name = make_benchmark_name entry in Re.execp regexp name) let get_matching_tests ~libname patterns = let tbl = Int.Table.create () in let entries = Ppx_bench_lib.Benchmark_accumulator.lookup_lib ~libname in let entries = match patterns with (* if no regexes are specified not specified, run all entries *) | [] -> entries | _ :: _ -> List.dedup_and_sort ~compare:Entry.compare (List.concat_map patterns ~f:(fun pattern -> let entries = List.filter entries ~f:(pattern_to_predicate pattern) in if List.is_empty entries then printf "Warning: %s didn't match any benchmark\n" pattern; entries)) in let tests = List.map entries ~f:(fun entry -> let key = entry.Entry.unique_id in Hashtbl.add_exn tbl ~key ~data:entry; entry_to_bench_test entry ~key) in tbl, tests let get_matching_tests_no_dups ~libname patterns = let _tbl, tests = get_matching_tests ~libname patterns in let tests = List.dedup_and_sort tests ~compare:(fun t1 t2 -> String.compare (Bench.Test.name t1) (Bench.Test.name t2)) in tests
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>