Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | import b from "benny";
|
---|
2 | import { build } from "../index";
|
---|
3 | import { initWebAssembly } from "../wasm";
|
---|
4 | import { toSummary } from "../Histogram";
|
---|
5 | initWebAssembly().then(() => {
|
---|
6 | const randomInteger = (max: number = Number.MAX_SAFE_INTEGER) =>
|
---|
7 | Math.floor(Math.random() * max);
|
---|
8 | const options = { initCount: 100 };
|
---|
9 |
|
---|
10 | b.suite(
|
---|
11 | "Histogram toJSON()",
|
---|
12 | b.add(
|
---|
13 | "JS 32B Histogram",
|
---|
14 | () => {
|
---|
15 | const histogram = build({
|
---|
16 | bitBucketSize: 32
|
---|
17 | });
|
---|
18 | for (let index = 0; index < 1024; index++) {
|
---|
19 | histogram.recordValueWithCount(randomInteger(), randomInteger(100));
|
---|
20 | }
|
---|
21 | return () => {
|
---|
22 | toSummary(histogram);
|
---|
23 | };
|
---|
24 | },
|
---|
25 | options
|
---|
26 | ),
|
---|
27 |
|
---|
28 | b.add(
|
---|
29 | "WASM 32B Histogram",
|
---|
30 | () => {
|
---|
31 | const histogram = build({
|
---|
32 | bitBucketSize: 32,
|
---|
33 | useWebAssembly: true
|
---|
34 | });
|
---|
35 | for (let index = 0; index < 1024; index++) {
|
---|
36 | histogram.recordValueWithCount(randomInteger(), randomInteger(100));
|
---|
37 | }
|
---|
38 | return () => {
|
---|
39 | toSummary(histogram);
|
---|
40 | };
|
---|
41 | },
|
---|
42 | options
|
---|
43 | ),
|
---|
44 | b.add(
|
---|
45 | "Packed Histogram",
|
---|
46 | () => {
|
---|
47 | const histogram = build({
|
---|
48 | bitBucketSize: "packed"
|
---|
49 | });
|
---|
50 | for (let index = 0; index < 1024; index++) {
|
---|
51 | histogram.recordValueWithCount(randomInteger(), randomInteger(100));
|
---|
52 | }
|
---|
53 | return () => {
|
---|
54 | toSummary(histogram);
|
---|
55 | };
|
---|
56 | },
|
---|
57 | options
|
---|
58 | ),
|
---|
59 | b.add(
|
---|
60 | "WASM Packed Histogram",
|
---|
61 | () => {
|
---|
62 | const histogram = build({
|
---|
63 | bitBucketSize: "packed",
|
---|
64 | useWebAssembly: true
|
---|
65 | });
|
---|
66 | for (let index = 0; index < 1024; index++) {
|
---|
67 | histogram.recordValueWithCount(randomInteger(), randomInteger(100));
|
---|
68 | }
|
---|
69 | return () => {
|
---|
70 | toSummary(histogram);
|
---|
71 | };
|
---|
72 | },
|
---|
73 | options
|
---|
74 | ),
|
---|
75 |
|
---|
76 | b.complete(),
|
---|
77 | b.save({ file: "json-percentile", format: "chart.html" })
|
---|
78 | );
|
---|
79 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.