Skip to content

Commit

Permalink
Calculate statistics in a single pass
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed May 8, 2023
1 parent 75e3cae commit 50810d4
Show file tree
Hide file tree
Showing 9 changed files with 580 additions and 751 deletions.
30 changes: 16 additions & 14 deletions src/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,19 @@ function toDataSetWithFastSlowBackground(data: ChangeData): any[] {
];
}

export function createCanvas(
height: number,
width: number,
outputType: 'svg' | 'png' = 'png',
plotType: 'boxplot' | 'violin' = 'boxplot'
): ChartJSNodeCanvas {
export interface CanvasSettings {
height: number;
width: number;
outputType: 'svg' | 'png';
plotType: 'boxplot' | 'violin';
}

export function createCanvas(settings: CanvasSettings): ChartJSNodeCanvas {
const plugins: any[] = ['chartjs-plugin-annotation'];

const canvasOptions: ChartJSNodeCanvasOptions = {
width,
height,
width: settings.width,
height: settings.height,
backgroundColour: siteAesthetics.backgroundColor,
plugins: { modern: plugins },
chartCallback: (ChartJS) => {
Expand All @@ -154,7 +156,7 @@ export function createCanvas(
}
});

if (plotType === 'boxplot') {
if (settings.plotType === 'boxplot') {
ChartJS.register(BoxPlotController, BoxAndWiskers);
ChartJS.registry.addControllers(BoxPlotController, BoxAndWiskers);
ChartJS.registry.addElements(BoxAndWiskers);
Expand All @@ -166,7 +168,7 @@ export function createCanvas(
}
};

if (outputType === 'svg') {
if (settings.outputType === 'svg') {
(<any>canvasOptions).type = 'svg'; // work around the readonly property
}
return new ChartJSNodeCanvas(canvasOptions);
Expand Down Expand Up @@ -249,12 +251,12 @@ export async function renderOverviewComparison(
outputType: 'svg' | 'png' = 'png',
plotType: 'boxplot' | 'violin' = 'boxplot'
): Promise<Buffer> {
const chartJSNodeCanvas = createCanvas(
calculatePlotHeight(title, data),
siteAesthetics.overviewPlotWidth,
const chartJSNodeCanvas = createCanvas({
height: calculatePlotHeight(title, data),
width: siteAesthetics.overviewPlotWidth,
outputType,
plotType
);
});

return renderDataOnCanvas(
chartJSNodeCanvas,
Expand Down
4 changes: 3 additions & 1 deletion src/db-data-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ function findOrConstructMeasurements(
values: [],
envId: row.envid,
commitId: row.commitid,
runSettings: runSetting
runSettings: runSetting,
runId: row.runid,
trialId: row.trialid
};
benchResult.measurements.push(m);
forSuiteByBench.criteria[criterion.name] = criterion;
Expand Down
5 changes: 3 additions & 2 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import pg, { PoolConfig, QueryConfig, QueryResultRow } from 'pg';
import { getDirname, TotalCriterion } from './util.js';
import { assert } from './logging.js';
import { simplifyCmdline } from './views/util.js';
import { ComparisonStatistics, SummaryStatistics } from './stats.js';
import { SummaryStatistics } from './stats.js';
import { BatchingTimelineUpdater } from './timeline-calc.js';

const __dirname = getDirname(import.meta.url);
Expand Down Expand Up @@ -229,10 +229,11 @@ export interface Measurements {
values: number[][];

envId: number;
runId: number;
trialId: number;
runSettings: RunSettings;
commitId: string;
stats?: SummaryStatistics;
changeStats?: ComparisonStatistics;
}

export interface ProcessedResult {
Expand Down
Loading

0 comments on commit 50810d4

Please sign in to comment.