Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-27 19:36:55 +00:00
parent e8b9dd6d0e
commit ba567f4017
109 changed files with 1138 additions and 1679 deletions

View File

@@ -25,4 +25,6 @@ async function createStreamVisualizer(asyncIterable, options) {
return { data, path };
}
export default createStreamVisualizer;
export default createStreamVisualizer;
// Generation time: 5.230s
// Result: PASS

View File

@@ -4,30 +4,29 @@ export async function createStreamVisualizer(asyncIterable, options) {
const data = [];
let prevEma;
for await (const { timestamp, value } of asyncIterable) {
const ema = prevEma === undefined
? value
: alpha * value + (1 - alpha) * prevEma;
const ema = prevEma === undefined ? value : alpha * value + (1 - alpha) * prevEma;
prevEma = ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
prevEma = ema;
}
const xScale = d3.scaleLinear()
.domain([data[0].timestamp, data[data.length - 1].timestamp])
.range([0, width]);
const yScale = d3.scaleLinear()
.domain(yDomain)
.range([height, 0]);
const path = d3.line()
.x(d => xScale(d.timestamp))
.y(d => yScale(d.ema))
(data);
return { data, path };
}
export default createStreamVisualizer;
export default createStreamVisualizer;
// Generation time: 4.236s
// Result: PASS

View File

@@ -1,33 +0,0 @@
async function createStreamVisualizer(
asyncIterable,
{ maxPoints, alpha, width, height, yDomain }
) {
const { scaleLinear, line } = await import('d3');
const data = [];
let ema = null;
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 < 2) {
return { data, path: "" };
}
const x = scaleLinear(
[data[0].timestamp, data.at(-1).timestamp],
[0, width]
);
const y = scaleLinear(yDomain, [height, 0]);
const path = line()
.x(p => x(p.timestamp))
.y(p => y(p.ema))(data);
return { data, path };
}
export default createStreamVisualizer;

View File

@@ -1,23 +1,23 @@
export const createStreamVisualizer = async (stream, { maxPoints, alpha, width, height, yDomain }) => {
const { scaleLinear, scaleTime, line } = await import('https://esm.sh/d3@7');
export const createStreamVisualizer = async (stream, { maxPoints: M, alpha: A, width: W, height: H, yDomain: Y }) => {
const { scaleLinear, line } = await import('https://esm.sh/d3');
const data = [];
let ema;
for await (const { timestamp, value } of stream) {
ema = ema === undefined ? value : alpha * value + (1 - alpha) * ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
for await (const { timestamp: t, value: v } of stream) {
ema = ema == null ? v : A * v + (1 - A) * ema;
data.push({ timestamp: t, value: v, ema });
if (data.length > M) data.shift();
}
if (!data.length) return { data, path: '' };
const x = scaleTime()
.domain([data[0].timestamp, data.at(-1).timestamp])
.range([0, width]);
const x = scaleLinear()
.domain([data[0].timestamp, data[data.length - 1].timestamp])
.range([0, W]);
const y = scaleLinear()
.domain(yDomain)
.range([height, 0]);
.domain(Y)
.range([H, 0]);
const path = line()
.x(d => x(d.timestamp))
@@ -25,4 +25,6 @@ export const createStreamVisualizer = async (stream, { maxPoints, alpha, width,
return { data, path };
};
export default createStreamVisualizer;
export default createStreamVisualizer;
// Generation time: 18.404s
// Result: PASS

View File

@@ -1,20 +1,21 @@
export async function createStreamVisualizer(stream, { maxPoints, alpha, width, height, yDomain }) {
const d3 = await import('d3');
const data = [];
let ema = null;
async function createStreamVisualizer(asyncIterable, { maxPoints, alpha, width, height, yDomain }) {
const d3 = await import('d3'), data = [];
let pe;
for await (const { timestamp, value } of stream) {
ema = ema === null ? value : alpha * value + (1 - alpha) * ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
for await (const { timestamp: t, value: v } of asyncIterable) {
const ema = pe === undefined ? v : alpha * v + (1 - alpha) * pe;
pe = ema;
data.push({ timestamp: t, value: v, ema });
data.length > maxPoints && data.shift();
}
if (!data.length) return { data, path: '' };
if (!data.length) return { data: [], path: '' };
const x = d3.scaleLinear().domain([data[0].timestamp, data[data.length - 1].timestamp]).range([0, width]);
const x = d3.scaleLinear().domain([data[0].timestamp, data.at(-1).timestamp]).range([0, width]);
const y = d3.scaleLinear().domain(yDomain).range([height, 0]);
const path = d3.line().x(d => x(d.timestamp)).y(d => y(d.ema))(data);
return { data, path };
return { data, path: d3.line().x(d => x(d.timestamp)).y(d => y(d.ema))(data) };
}
export default createStreamVisualizer;
export default createStreamVisualizer;
// Generation time: 81.116s
// Result: FAIL

View File

@@ -1,20 +1,21 @@
const createStreamVisualizer = async (src, opt = {}) => {
const { maxPoints = 100, alpha = 0.5, width = 600, height = 300, yDomain = [0, 1] } = opt
const { scaleLinear, line } = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm')
const data = []
async function createStreamVisualizer(iterable,options={}){
const{maxPoints=100,alpha=.3,width=640,height=320,yDomain=[0,1]}=options
const{scaleLinear,line}=await import('https://cdn.jsdelivr.net/npm/d3@7/+esm')
const data=[]
let ema
for await (const p of src) {
if (!p) continue
const { timestamp: t, value: v } = p
if (t == null || v == null) continue
ema = ema == null ? v : alpha * v + (1 - alpha) * ema
data.push({ timestamp: t, value: v, ema })
data.length > maxPoints && data.shift()
for await(const{timestamp,value}of iterable){
ema=ema==null?value:alpha*value+(1-alpha)*ema
data.push({timestamp,value,ema})
data.length>maxPoints&&data.shift()
}
if (!data.length) return { data, path: '' }
const x = scaleLinear().domain([data[0].timestamp, data.at(-1).timestamp]).range([0, width])
const y = scaleLinear().domain(yDomain).range([height, 0])
const path = line().x(d => x(d.timestamp)).y(d => y(d.ema))(data) || ''
return { data, path }
let path=''
if(data.length){
const x=scaleLinear().domain([data[0].timestamp,data.at(-1).timestamp]).range([0,width])
const y=scaleLinear().domain(yDomain).range([height,0])
path=line().x(d=>x(d.timestamp)).y(d=>y(d.ema))(data)||''
}
return{data,path}
}
export default createStreamVisualizer;
export default createStreamVisualizer;
// Generation time: 10.093s
// Result: PASS

View File

@@ -1,41 +0,0 @@
const createStreamVisualizer = async (asyncIterable, {
maxPoints = 1000,
alpha = 0.3,
width = 800,
height = 400,
yDomain = [0, 1]
} = {}) => {
const { scaleLinear, line } = await import('https://cdn.skypack.dev/d3@7');
const data = [];
let prevEma;
for await (const { timestamp, value } of asyncIterable) {
const ema = prevEma === undefined
? value
: alpha * value + (1 - alpha) * prevEma;
prevEma = ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
}
if (!data.length) return { data: [], path: '' };
const xScale = scaleLinear()
.domain([data[0].timestamp, data[data.length - 1].timestamp])
.range([0, width]);
const yScale = scaleLinear()
.domain(yDomain)
.range([height, 0]);
const pathGenerator = line()
.x(d => xScale(d.timestamp))
.y(d => yScale(d.ema));
return {
data,
path: pathGenerator(data)
};
};
export default createStreamVisualizer;

View File

@@ -1,17 +0,0 @@
async function createStreamVisualizer(iter,opts={}){
const{maxPoints:mp=1e3,alpha:a=.1,width:w=800,height:h=400,yDomain:yd=[0,1]}=opts;
let data=[],pE=null;
for await(const{timestamp:t,value:v}of iter){
let ema=pE===null?v:a*v+(1-a)*pE;
pE=ema;
data.push({timestamp:t,value:v,ema});
if(data.length>mp)data.shift();
}
if(!data.length)return{data,path:null};
const d3=await import('https://cdn.skypack.dev/d3');
const x=d3.scaleLinear().domain([data[0].timestamp,data.at(-1).timestamp]).range([0,w]);
const y=d3.scaleLinear().domain(yd).range([h,0]);
const ln=d3.line().x(d=>x(d.timestamp)).y(d=>y(d.ema));
return{data,path:ln(data)};
}
export default createStreamVisualizer;

View File

@@ -1,21 +0,0 @@
async function createStreamVisualizer(iter,opts){
const d3=await import('https://cdn.skypack.dev/d3');
const {maxPoints=500,alpha=.1,width=800,height=400,yDomain:[0,1]}=opts;
let data=[],prevEma=null;
for await(const {timestamp:t,value:v}of iter){
const ema=prevEma===null?v:alpha*v+(1-alpha)*prevEma;
prevEma=ema;
data.push({timestamp:t,value:v,ema});
if(data.length>maxPoints)data.shift();
}
if(data.length<2)return{data,path:"M 0 0"};
const x0=data[0].timestamp,x1=data.at(-1).timestamp;
const xScale=d3.scaleLinear().domain([x0,x1]).range([0,width]);
const yScale=d3.scaleLinear().domain(yDomain).range([height,0]);
const line=d3.line()
.x(d=>xScale(d.timestamp))
.y(d=>yScale(d.ema))
.curve(d3.curveMonotoneX);
return{data,path:line(data)};
}
export default createStreamVisualizer;

View File

@@ -0,0 +1,35 @@
async function createStreamVisualizer(asyncIterable, options) {
const { maxPoints, alpha, width, height, yDomain } = options;
const d3 = await import('d3');
const data = [];
let prevEma = null;
let first = true;
for await (const { timestamp, value } of asyncIterable) {
let ema;
if (first) {
ema = value;
prevEma = value;
first = false;
} else {
ema = alpha * value + (1 - alpha) * prevEma;
prevEma = ema;
}
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
}
if (data.length === 0) return { data, path: '' };
const x = d3.scaleLinear()
.domain([data[0].timestamp, data[data.length - 1].timestamp])
.range([0, width]);
const y = d3.scaleLinear()
.domain(yDomain)
.range([height, 0]);
const line = d3.line()
.x(d => x(d.timestamp))
.y(d => y(d.ema));
const path = line(data);
return { data, path };
}
export default createStreamVisualizer;
// Generation time: 34.223s
// Result: FAIL