histogram-data-access.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const benny_1 = require("benny");
  4. const index_1 = require("../index");
  5. const wasm_1 = require("../wasm");
  6. wasm_1.initWebAssembly().then(() => {
  7. const randomInteger = () => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
  8. const options = { initCount: 1000 };
  9. benny_1.default.suite("Histogram data access", benny_1.default.add("Int32Histogram", () => {
  10. const histogram = index_1.build({ bitBucketSize: 32 });
  11. return () => {
  12. histogram.recordValue(randomInteger());
  13. };
  14. }, options), benny_1.default.add("PackedHistogram", () => {
  15. const histogram = index_1.build({ bitBucketSize: "packed" });
  16. return () => {
  17. histogram.recordValue(randomInteger());
  18. };
  19. }, options), benny_1.default.add("Float64Histogram", () => {
  20. const histogram = index_1.build({ bitBucketSize: 64 });
  21. return () => {
  22. histogram.recordValue(randomInteger());
  23. };
  24. }, options), benny_1.default.add("Int32Histogram eager allocation", () => {
  25. const histogram = index_1.build({
  26. bitBucketSize: 32,
  27. highestTrackableValue: Number.MAX_SAFE_INTEGER
  28. });
  29. return () => {
  30. histogram.recordValue(randomInteger());
  31. };
  32. }, options), benny_1.default.add("WASM Int32Histogram", () => {
  33. const histogram = index_1.build({
  34. useWebAssembly: true
  35. });
  36. return () => {
  37. histogram.recordValue(randomInteger());
  38. };
  39. }, options), benny_1.default.add("WASM PackedHistogram", () => {
  40. const histogram = index_1.build({
  41. useWebAssembly: true
  42. });
  43. return () => {
  44. histogram.recordValue(randomInteger());
  45. };
  46. }, options), benny_1.default.add("Float64Histogram eager allocation", () => {
  47. const histogram = index_1.build({
  48. bitBucketSize: 64,
  49. highestTrackableValue: Number.MAX_SAFE_INTEGER
  50. });
  51. return () => {
  52. histogram.recordValue(randomInteger());
  53. };
  54. }, options), benny_1.default.complete(), benny_1.default.save({ file: "data-access", format: "chart.html" }));
  55. });
  56. //# sourceMappingURL=histogram-data-access.js.map