Published
Edited
May 20, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// {
// let d = filterByMethod(data, copyMethods);
// let sizesByComputer = {};
// d.forEach(row => {
// let computer = row.Computer;
// let sizes = sizesByComputer[computer] = sizesByComputer[computer] || new Set();
// sizes.add(row["Image width"])
// });
// return vl
// .markBar()
// .data(d.filter(row => sizesByComputer[row.Computer].size > 2))
// .encode(
// vl.column().fieldO("Method").sort(methodNames),
// vl.row().fieldN("Computer"),
// vl
// .x()
// .fieldQ("Image width")
// ,
// vl.y().average("FPS"),
// vl
// .tooltip()
// .average("FPS")
// .format(",")
// )
// .render()
// }
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
let hasData = row => row.Computer && row.Method && row['ms/copy'] > 0;
function normalizeRow(row) {
row.Computer = row.Computer.replace(/macbook/i, "MacBook").trim();
row.FPS = Number(String(row.FPS).replace(/,/g, ''));
}
let p5data = await FileAttachment("p5.js pixel timings - Sheet1@3.csv").csv({
typed: true
});
let processingData = await FileAttachment(
"p5.js pixel timings - Sheet2.csv"
).csv({
typed: true
});
let data = [...p5data, ...processingData.slice(0, 18)].filter(hasData);
data.forEach(normalizeRow);
data = data.filter(row => row.FPS !== 121_225); // FIXME
return data;
}
Insert cell
p5data = filterByField(data, 'Platform', 'p5.js')
Insert cell
(await FileAttachment("p5.js pixel timings - Sheet2.csv").csv({
typed: true
})).slice(0, 16)
Insert cell
standardWidthData = filterByField(p5data, 'Image width', 200)
Insert cell
// a list of method names, in order of initial occurrence
methodNames = Array.from(new Set(data.map(r => r.Method)))
Insert cell
pixelCopyMethods = methodNames.filter(name => !name.match(/10%/))
Insert cell
pixelMethods = pixelCopyMethods.filter(name => !name.match(/image/))
Insert cell
nonCopyMethods = methodNames.filter(name => !pixelCopyMethods.includes(name))
Insert cell
methodReporterCounts = {
let methodReporters = {};
data.forEach(row => {
let key = row.Method;
methodReporters[key] = methodReporters[key] || new Set();
methodReporters[key].add(row.Reporter);
});
return Object.fromEntries(
Object.entries(methodReporters).map(([k, v]) => [k, v.size])
);
}
Insert cell
Insert cell
filterByMethod = (data, methods) => filterByField(data, 'Method', methods);
Insert cell
function filterByField(data, fieldName, value) {
const test = Array.isArray(value)
? row => value.includes(row[fieldName])
: row => row[fieldName] === value;
return data.filter(test);
}
Insert cell
// `rows` is an Array of Objects with property `key`. Return a copy of the array
// that includes only those objects whose `key` is fewer than three standard deviations from the mean.
function removeOutliers(rows, key = "FPS") {
let values = rows.map(row => row[key]);
let mean = d3.mean(values);
let sd = d3.deviation(values);
return rows.filter(row => Math.abs(row[key] - mean) < 3 * sd);
}
Insert cell
Insert cell
import { vl } from "@vega/vega-lite-api"
Insert cell
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