mirror of
https://github.com/home-assistant/frontend.git
synced 2026-07-02 03:55:52 +01:00
133a9171bc
* Add deterministic fixtures and characterization tests for chart data processing * Extract statistics chart data processing into a pure function * Extract state history line chart data processing into a pure function * Add benchmark suite for chart data processing * Add chart data optimization playbook * Point agent instructions at the chart optimization playbook
19 lines
574 B
TypeScript
19 lines
574 B
TypeScript
/**
|
|
* Deterministic seeded PRNG (mulberry32) for reproducible fixtures.
|
|
* The same seed always yields the same sequence, so characterization
|
|
* tests and benchmarks operate on identical data across runs.
|
|
*/
|
|
/* eslint-disable no-bitwise */
|
|
export type SeededRandom = () => number;
|
|
|
|
export const createSeededRandom = (seed: number): SeededRandom => {
|
|
let a = seed >>> 0;
|
|
return () => {
|
|
a += 0x6d2b79f5;
|
|
let t = a;
|
|
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
};
|
|
};
|