Published
Edited
Nov 18, 2020
Also listed in…
Observable
Insert cell
Insert cell
times = new Promise(resolve => {
const ts = [];
const timer = d3.timer(function(elapsed) {
ts.push(elapsed);
if (elapsed > 2000) {
timer.stop();
resolve(ts);
}
});
})
Insert cell
m = d3.median(d3.pairs(times, (a, b) => b - a))
Insert cell
times2 = new Promise(resolve => {
let lastRequest;
const ts = [];
const start = performance.now();
function callback() {
const elapsed = performance.now();
ts.push(elapsed);
if (elapsed - start < 2000) {
requestAnimationFrame(callback);
} else {
resolve(ts);
}
}
callback();
})
Insert cell
m2 = d3.median(d3.pairs(times2, (a, b) => b - a))
Insert cell
d3 = require('d3@6')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more