[6a3a178] | 1 | import b from "benny";
|
---|
| 2 | import { build } from "../index";
|
---|
| 3 | import { initWebAssembly } from "../wasm";
|
---|
| 4 | initWebAssembly().then(() => {
|
---|
| 5 | const randomInteger = () => Math.floor(Math.random() * 1000000);
|
---|
| 6 | const randomSmallInteger = () => Math.floor(Math.random() * 1000);
|
---|
| 7 | const options = { initCount: 1000 };
|
---|
| 8 |
|
---|
| 9 | b.suite(
|
---|
| 10 | "Histogram data access with coordinated ommissions",
|
---|
| 11 | b.add(
|
---|
| 12 | "Int32Histogram",
|
---|
| 13 | () => {
|
---|
| 14 | const histogram = build({ bitBucketSize: 32 });
|
---|
| 15 | return () => {
|
---|
| 16 | histogram.recordValueWithExpectedInterval(randomInteger(), 100000);
|
---|
| 17 | };
|
---|
| 18 | },
|
---|
| 19 | options
|
---|
| 20 | ),
|
---|
| 21 |
|
---|
| 22 | b.add(
|
---|
| 23 | "Int32Histogram no correction needed",
|
---|
| 24 | () => {
|
---|
| 25 | const histogram = build({ bitBucketSize: 32 });
|
---|
| 26 | return () => {
|
---|
| 27 | histogram.recordValueWithExpectedInterval(
|
---|
| 28 | randomSmallInteger(),
|
---|
| 29 | 100000
|
---|
| 30 | );
|
---|
| 31 | };
|
---|
| 32 | },
|
---|
| 33 | options
|
---|
| 34 | ),
|
---|
| 35 | b.add(
|
---|
| 36 | "PackedHistogram",
|
---|
| 37 | () => {
|
---|
| 38 | const histogram = build({ bitBucketSize: "packed" });
|
---|
| 39 | return () => {
|
---|
| 40 | histogram.recordValueWithExpectedInterval(randomInteger(), 100000);
|
---|
| 41 | };
|
---|
| 42 | },
|
---|
| 43 | options
|
---|
| 44 | ),
|
---|
| 45 | b.add(
|
---|
| 46 | "PackedHistogram no correction needed",
|
---|
| 47 | () => {
|
---|
| 48 | const histogram = build({ bitBucketSize: "packed" });
|
---|
| 49 | return () => {
|
---|
| 50 | histogram.recordValueWithExpectedInterval(
|
---|
| 51 | randomSmallInteger(),
|
---|
| 52 | 100000
|
---|
| 53 | );
|
---|
| 54 | };
|
---|
| 55 | },
|
---|
| 56 | options
|
---|
| 57 | ),
|
---|
| 58 |
|
---|
| 59 | b.add(
|
---|
| 60 | "WASM Int32Histogram",
|
---|
| 61 | () => {
|
---|
| 62 | const histogram = build({
|
---|
| 63 | useWebAssembly: true
|
---|
| 64 | });
|
---|
| 65 | return () => {
|
---|
| 66 | histogram.recordValueWithExpectedInterval(randomInteger(), 100000);
|
---|
| 67 | };
|
---|
| 68 | },
|
---|
| 69 | options
|
---|
| 70 | ),
|
---|
| 71 |
|
---|
| 72 | b.add(
|
---|
| 73 | "WASM Int32Histogram no correction needed",
|
---|
| 74 | () => {
|
---|
| 75 | const histogram = build({
|
---|
| 76 | useWebAssembly: true
|
---|
| 77 | });
|
---|
| 78 | return () => {
|
---|
| 79 | histogram.recordValueWithExpectedInterval(
|
---|
| 80 | randomSmallInteger(),
|
---|
| 81 | 100000
|
---|
| 82 | );
|
---|
| 83 | };
|
---|
| 84 | },
|
---|
| 85 | options
|
---|
| 86 | ),
|
---|
| 87 |
|
---|
| 88 | b.add(
|
---|
| 89 | "WASM PackedHistogram",
|
---|
| 90 | () => {
|
---|
| 91 | const histogram = build({
|
---|
| 92 | useWebAssembly: true,
|
---|
| 93 | bitBucketSize: "packed"
|
---|
| 94 | });
|
---|
| 95 | return () => {
|
---|
| 96 | histogram.recordValueWithExpectedInterval(randomInteger(), 100000);
|
---|
| 97 | };
|
---|
| 98 | },
|
---|
| 99 | options
|
---|
| 100 | ),
|
---|
| 101 |
|
---|
| 102 | b.add(
|
---|
| 103 | "WASM PackedHistogram no correction needed",
|
---|
| 104 | () => {
|
---|
| 105 | const histogram = build({
|
---|
| 106 | useWebAssembly: true,
|
---|
| 107 | bitBucketSize: "packed"
|
---|
| 108 | });
|
---|
| 109 | return () => {
|
---|
| 110 | histogram.recordValueWithExpectedInterval(
|
---|
| 111 | randomSmallInteger(),
|
---|
| 112 | 100000
|
---|
| 113 | );
|
---|
| 114 | };
|
---|
| 115 | },
|
---|
| 116 | options
|
---|
| 117 | ),
|
---|
| 118 | b.complete(),
|
---|
| 119 | b.save({ file: "data-access-co", format: "chart.html" })
|
---|
| 120 | );
|
---|
| 121 | });
|
---|