summaryrefslogtreecommitdiff
path: root/evals/fixtures/performance-optimization/benchmark.js
blob: 7c4422a21524ed3f7cbdc42609d722d3b08941c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'use strict';

const { performance } = require('node:perf_hooks');
const { renderProducts } = require('./products');

const products = Array.from({ length: 1000 }, (_, id) => ({
  id,
  name: `Product ${id}`,
  sales: (id * 7919) % 10000,
}));

const start = performance.now();
const output = renderProducts(products);
const elapsed = performance.now() - start;
console.log(JSON.stringify({ products: products.length, bytes: output.length, elapsedMs: elapsed }));