Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-18 23:31:52 +00:00
parent 341252fec1
commit 5855cf8a6f
77 changed files with 972 additions and 1051 deletions

View File

@@ -1,50 +1,33 @@
async function createStreamVisualizer(asyncIterable, {
maxPoints,
alpha,
width,
height,
yDomain
}) {
const {
scaleLinear,
line
} = await import('d3');
async function createStreamVisualizer(
asyncIterable,
{ maxPoints, alpha, width, height, yDomain }
) {
const { scaleLinear, line } = await import('d3');
const data = [];
let prevEma;
let ema = null;
for await (const { value, timestamp } of asyncIterable) {
prevEma = (prevEma === undefined) ?
value :
alpha * value + (1 - alpha) * prevEma;
data.push({
timestamp,
value,
ema: prevEma
});
for await (const point of asyncIterable) {
ema = ema === null ? point.value : alpha * point.value + (1 - alpha) * ema;
data.push({ ...point, ema });
if (data.length > maxPoints) {
data.shift();
}
}
if (!data.length) {
return {
data,
path: ''
};
if (data.length < 2) {
return { data, path: "" };
}
const x = scaleLinear([data[0].timestamp, data.at(-1).timestamp], [0, width]);
const x = scaleLinear(
[data[0].timestamp, data.at(-1).timestamp],
[0, width]
);
const y = scaleLinear(yDomain, [height, 0]);
const path = line()
.x(d => x(d.timestamp))
.y(d => y(d.ema))(data);
.x(p => x(p.timestamp))
.y(p => y(p.ema))(data);
return {
data,
path: path ?? ''
};
return { data, path };
}
export default createStreamVisualizer;