Dev Helpers
← Back

Calculate a histogram mean

Calculate a histogram mean using Node.js.

Open this example in the interactive library

Source code

import {
  performance,
  createHistogram,
  PerformanceObserver,
} from "node:perf_hooks";
console.log(
  (() => {
    const h = createHistogram();
    h.record(2);
    h.record(8);
    return h.mean;
  })(),
);

Sample output

5