mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 16:47:55 +00:00
Docs: Update benchmark results
This commit is contained in:
23
tests/9_stream_visualizer/outputs/openai_gpt-5.1-chat.js
Normal file
23
tests/9_stream_visualizer/outputs/openai_gpt-5.1-chat.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export async function createStreamVisualizer(iter, o) {
|
||||
const { maxPoints, alpha, width, height, yDomain } = o
|
||||
const d3 = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm')
|
||||
const data = []
|
||||
let ema
|
||||
for await (const { timestamp, value } of iter) {
|
||||
ema = ema == null ? value : alpha * value + (1 - alpha) * ema
|
||||
data.push({ timestamp, value, ema })
|
||||
if (data.length > maxPoints) data.shift()
|
||||
}
|
||||
const xs = d3.scaleLinear()
|
||||
.domain([data[0].timestamp, data[data.length - 1].timestamp])
|
||||
.range([0, width])
|
||||
const ys = d3.scaleLinear()
|
||||
.domain(yDomain)
|
||||
.range([height, 0])
|
||||
const line = d3.line()
|
||||
.x(d => xs(d.timestamp))
|
||||
.y(d => ys(d.ema))
|
||||
const path = line(data) || ''
|
||||
return { data, path }
|
||||
}
|
||||
export default createStreamVisualizer;
|
||||
Reference in New Issue
Block a user