MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / generateNumbers

Function generateNumbers

test/compute-engine/performance.test.ts:8–22  ·  view source on GitHub ↗

* Linear Congruential Generator for deterministic pseudo-random numbers. * Constants from the classic C rand() implementation.

(n: number, seed = 0)

Source from the content-addressed store, hash-verified

6 * Constants from the classic C rand() implementation.
7 */
8function generateNumbers(n: number, seed = 0): number[] {
9 const results: number[] = [];
10 let current = seed;
11
12 const a = 1664525;
13 const c = 1013904223;
14 const m = 2 ** 32;
15
16 for (let i = 0; i < n; i++) {
17 current = (a * current + c) % m;
18 results.push(current);
19 }
20
21 return results;
22}
23
24/** Establish a baseline for computation performance in JS.
25 * Compute Engine calculations will be measured against this.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected