source: trip-planner-front/node_modules/hdr-histogram-js/src/bench/histogram-data-access.ts@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1import b from "benny";
2import { build } from "../index";
3import { initWebAssembly } from "../wasm";
4initWebAssembly().then(() => {
5 const randomInteger = () =>
6 Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
7 const options = { initCount: 1000 };
8
9 b.suite(
10 "Histogram data access",
11 b.add(
12 "Int32Histogram",
13 () => {
14 const histogram = build({ bitBucketSize: 32 });
15 return () => {
16 histogram.recordValue(randomInteger());
17 };
18 },
19 options
20 ),
21 b.add(
22 "PackedHistogram",
23 () => {
24 const histogram = build({ bitBucketSize: "packed" });
25 return () => {
26 histogram.recordValue(randomInteger());
27 };
28 },
29 options
30 ),
31 b.add(
32 "Float64Histogram",
33 () => {
34 const histogram = build({ bitBucketSize: 64 });
35 return () => {
36 histogram.recordValue(randomInteger());
37 };
38 },
39 options
40 ),
41 b.add(
42 "Int32Histogram eager allocation",
43 () => {
44 const histogram = build({
45 bitBucketSize: 32,
46 highestTrackableValue: Number.MAX_SAFE_INTEGER
47 });
48 return () => {
49 histogram.recordValue(randomInteger());
50 };
51 },
52 options
53 ),
54 b.add(
55 "WASM Int32Histogram",
56 () => {
57 const histogram = build({
58 useWebAssembly: true
59 });
60 return () => {
61 histogram.recordValue(randomInteger());
62 };
63 },
64 options
65 ),
66 b.add(
67 "WASM PackedHistogram",
68 () => {
69 const histogram = build({
70 useWebAssembly: true
71 });
72 return () => {
73 histogram.recordValue(randomInteger());
74 };
75 },
76 options
77 ),
78 b.add(
79 "Float64Histogram eager allocation",
80 () => {
81 const histogram = build({
82 bitBucketSize: 64,
83 highestTrackableValue: Number.MAX_SAFE_INTEGER
84 });
85 return () => {
86 histogram.recordValue(randomInteger());
87 };
88 },
89 options
90 ),
91 b.complete(),
92 b.save({ file: "data-access", format: "chart.html" })
93 );
94});
Note: See TracBrowser for help on using the repository browser.