Skip to content

Commit 31f328f

Browse files
committed
Merge branch 'master' of github.com:krausest/js-framework-benchmark
2 parents a6de18b + 84169f0 commit 31f328f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+16503
-8290
lines changed

webdriver-ts-results/.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
webpack.config.js
2-
.eslintrc.js
2+
.eslintrc.js
3+
src/results.ts

webdriver-ts-results/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const App = (): JSX.Element => {
1515
return (
1616
<div>
1717
{disclaimer}
18-
<p>The benchmark was run on a MacBook Pro 14 (32 GB RAM, 8/14 Cores, OSX 13.3), Chrome 112.0.5615.49 (arm64))
18+
<p>The benchmark was run on a MacBook Pro 14 (32 GB RAM, 8/14 Cores, OSX 13.3), Chrome 113.0.5672.63 (arm64))
1919
using the puppeteer benchmark driver with reduced tracing.
2020
</p>
2121
<SelectionBar/>

webdriver-ts-results/src/Common.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const jStat = require('jstat').jStat;
55

66
export enum StatisticResult {Slower, Undecided, Faster}
77
export enum DisplayMode { DisplayMean, DisplayMedian, BoxPlot }
8+
export enum CpuDurationMode { Total='total', Script='script'}
89

910
export enum FrameworkType { KEYED, NON_KEYED }
1011

@@ -35,6 +36,8 @@ export const categories: Category[] = [
3536
{id:6, text:"[Issue]: Errors in the implementation", issues: [634], severity: Severity.Error},
3637
]
3738

39+
const DEFAULT_RESULTS_KEY = 'DEFAULT';
40+
3841
interface IIssue {
3942
issue: number,
4043
severity: Severity,
@@ -64,19 +67,22 @@ export interface Benchmark {
6467
}
6568

6669
export interface RawResult {
67-
f: string;
68-
b: string;
69-
v: number[];
70+
f: string,
71+
b: string,
72+
v: {[k:string]: number[]}
7073
}
7174

72-
export interface Result {
73-
framework: string;
74-
benchmark: string;
75+
export interface ResultValues {
7576
values: number[];
7677
mean: number;
7778
median: number;
7879
standardDeviation: number;
7980
}
81+
export interface Result {
82+
framework: string;
83+
benchmark: string;
84+
results: {[key:string]: ResultValues};
85+
}
8086

8187
interface ResultData {
8288
benchmarks: Array<Benchmark>;
@@ -203,7 +209,8 @@ export class ResultTableData {
203209

204210
constructor(public allFrameworks: Array<Framework>, public allBenchmarks: Array<Benchmark>, public results: ResultLookup,
205211
public selectedFrameworksInDropdown: Set<Framework>, public selectedBenchmarks: Set<Benchmark>, type: FrameworkType, sortKey: string,
206-
public displayMode: DisplayMode, public compareWith: Framework|undefined, public selectedCategories: Set<number>) {
212+
public displayMode: DisplayMode, public compareWith: Framework|undefined, public selectedCategories: Set<number>,
213+
public cpuDurationMode: string) {
207214

208215
this.selectedFameworks = new Set<Framework>();
209216

@@ -341,13 +348,16 @@ export class ResultTableData {
341348
}
342349

343350
computeFactors(benchmark: Benchmark): Array<TableResultValueEntry|null> {
351+
352+
const resultsKey = benchmark.type == BenchmarkType.CPU ? this.cpuDurationMode : DEFAULT_RESULTS_KEY;
353+
344354
const benchmarkResults = this.frameworksForFactors.map(f => this.results(benchmark, f));
345355
const selectFn = (result: Result|null) => {
346356
if (result===null) return 0;
347357
if (this.displayMode === DisplayMode.DisplayMedian) {
348-
return result.median;
358+
return result.results[resultsKey].median;
349359
} else {
350-
return result.mean;
360+
return result.results[resultsKey].mean;
351361
}
352362
}
353363
const min = Math.max(benchmarkResults.reduce((min, result) => result===null ? min : Math.min(min, selectFn(result)), Number.POSITIVE_INFINITY));
@@ -357,32 +367,34 @@ export class ResultTableData {
357367
return this.frameworks.map(f => {
358368
const result = this.results(benchmark, f);
359369
if (result === null) return null;
370+
const resultValues = result.results[resultsKey];
360371

361372
const value = selectFn(result);
362373
const factor = value/min;
363374
// if (benchmark.type === BenchmarkType.CPU) {
364375
// factor = Math.max(1, factor);
365376
// }
366-
const conficenceInterval = 1.959964 * (result.standardDeviation || 0) / Math.sqrt(result.values.length);
377+
const conficenceInterval = 1.959964 * (resultValues.standardDeviation || 0) / Math.sqrt(resultValues.values.length);
367378
const conficenceIntervalStr = benchmark.type === BenchmarkType.MEM ? null : conficenceInterval.toFixed(1);
368379
const formattedValue = formatEn.format(value);
369380

370381
if (!this.compareWith) {
371382
return new TableResultValueEntry(f.name, value, formattedValue, conficenceIntervalStr, factor, factor.toFixed(2), computeColor(factor), '#000', StatisticResult.Undecided);
372383
} else {
373384
const compareWithResults = this.results(benchmark, this.compareWith)!;
385+
const compareWithResultsValues = compareWithResults.results[resultsKey]
374386
// let meanStr = 'x'; //mean.toLocaleString('en-US', {minimumFractionDigits: 1, maximumFractionDigits: 1, useGrouping: true});
375387

376388
// X1,..,Xn: this Framework, Y1, ..., Ym: selected Framework
377389
// https://de.wikipedia.org/wiki/Zweistichproben-t-Test
378390
let statisticalResult = undefined;
379391
let statisticalCol = undefined;
380-
const compareWithMean = compareWithResults.mean;
381-
const stdDev = result.standardDeviation || 0;
382-
const compareWithResultsStdDev = compareWithResults.standardDeviation || 0;
392+
const compareWithMean = compareWithResultsValues.mean;
393+
const stdDev = compareWithResultsValues.standardDeviation || 0;
394+
const compareWithResultsStdDev = compareWithResultsValues.standardDeviation || 0;
383395

384396

385-
const x1 = result.mean;
397+
const x1 = resultValues.mean;
386398
const x2 = compareWithMean;
387399
const s1_2 = stdDev*stdDev;
388400
const s2_2 = compareWithResultsStdDev * compareWithResultsStdDev;

webdriver-ts-results/src/ResultTable.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import {ResultTableData, DisplayMode, BenchmarkType, FrameworkType} from './Common';
2+
import {ResultTableData, DisplayMode, BenchmarkType, FrameworkType, CpuDurationMode} from './Common';
33
import CpuResultsTable from './tables/CpuResultsTable'
44
import MemResultsTable from './tables/MemResultsTable'
55
import StartupResultsTable from './tables/StartupResultsTable'
@@ -24,6 +24,7 @@ const ResultTable = ({type}: Props): JSX.Element|null => {
2424
const data = useSelector<State, ResultTableData|undefined>((state) => state.resultTables[type]);
2525
const currentSortKey = useSelector<State, string>((state) => state.sortKey);
2626
const displayMode = useSelector<State, DisplayMode>((state) => state.displayMode);
27+
const cpuDurationMode = useSelector<State, CpuDurationMode>((state) => state.cpuDurationMode);
2728
const sortBy = (sortKey: string) => dispatch(sort(sortKey))
2829

2930
if (data === undefined || data.frameworks.length===0 || (data.getResult(BenchmarkType.CPU).benchmarks.length===0 && data.getResult(BenchmarkType.STARTUP).benchmarks.length===0 && data.getResult(BenchmarkType.MEM).benchmarks.length===0)) return null;
@@ -33,11 +34,12 @@ const ResultTable = ({type}: Props): JSX.Element|null => {
3334
<div key={texts[type].label}>
3435
<h1>{texts[type].label}</h1>
3536
<p>{texts[type].description}</p>
37+
{cpuDurationMode==CpuDurationMode.Script && <h3>Warning: This is an experimental view. Don't rely on those values yet.</h3>}
3638
{
3739
displayMode === DisplayMode.BoxPlot ?
3840
(
3941
<React.Suspense fallback={<div>Loading...</div>}>
40-
<BoxPlotTable results={data.results} frameworks={data.frameworks} benchmarks={data.getResult(BenchmarkType.CPU).benchmarks} currentSortKey={currentSortKey} sortBy={sortBy}/>
42+
<BoxPlotTable results={data.results} frameworks={data.frameworks} benchmarks={data.getResult(BenchmarkType.CPU).benchmarks} currentSortKey={currentSortKey} sortBy={sortBy} cpuDurationMode={cpuDurationMode}/>
4143
</React.Suspense>
4244
)
4345
:

webdriver-ts-results/src/reducer.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Benchmark, BenchmarkType, convertToMap, DisplayMode, Framework, FrameworkType, RawResult, Result, ResultTableData, SORT_BY_GEOMMEAN_CPU, categories, Severity } from "./Common"
1+
import { Benchmark, BenchmarkType, convertToMap, DisplayMode, Framework, FrameworkType, RawResult, Result, ResultTableData, SORT_BY_GEOMMEAN_CPU, categories, Severity, ResultValues, CpuDurationMode } from "./Common"
22
import { benchmarks as benchmark_orig, frameworks, results as rawResults } from './results';
33

44
// Temporarily disable script bootup time
@@ -9,12 +9,20 @@ const benchmarks = benchmark_orig.filter(b => b.id !== '32_startup-bt'
99
// eslint-disable-next-line @typescript-eslint/no-var-requires
1010
const jStat = require('jstat').jStat;
1111

12-
const results: Result[] = (rawResults as RawResult[]).map(res => Object.assign(({ framework: res.f, benchmark: res.b, values: res.v }),
13-
{
14-
mean: res.v ? jStat.mean(res.v) : Number.NaN,
15-
median: res.v ? jStat.median(res.v) : Number.NaN,
16-
standardDeviation: res.v ? jStat.stdev(res.v, true) : Number.NaN
17-
}));
12+
const results: Result[] = (rawResults as RawResult[]).map(res => {
13+
const values: {[k: string]: ResultValues} = {};
14+
for (const key of Object.keys(res.v)) {
15+
const r = res.v[key];
16+
const vals = {
17+
mean: r ? jStat.mean(r) : Number.NaN,
18+
median: r ? jStat.median(r) : Number.NaN,
19+
standardDeviation: r ? jStat.stdev(r, true) : Number.NaN,
20+
values: r
21+
}
22+
values[key] = vals;
23+
}
24+
return { framework: res.f, benchmark: res.b, results: values}
25+
});
1826

1927
const removeKeyedSuffix = (value: string) => {
2028
if (value.endsWith('-non-keyed')) return value.substring(0, value.length - 10)
@@ -52,6 +60,7 @@ export interface State {
5260
displayMode: DisplayMode;
5361
compareWith: CompareWith;
5462
categories: Set<number>;
63+
cpuDurationMode: CpuDurationMode;
5564
}
5665

5766
export const areAllBenchmarksSelected = (state: State, type: BenchmarkType): boolean => state.benchmarkLists[type].every(b => state.selectedBenchmarks.has(b))
@@ -87,13 +96,14 @@ let preInitialState: State = {
8796
[FrameworkType.KEYED]: undefined,
8897
[FrameworkType.NON_KEYED]: undefined
8998
},
90-
categories: new Set(categories.filter(c => c.severity != Severity.Error).map(c => c.id))
99+
categories: new Set(categories.filter(c => c.severity != Severity.Error).map(c => c.id)),
100+
cpuDurationMode : CpuDurationMode.Total
91101
}
92102

93-
function updateResultTable({ frameworks, benchmarks, selectedFrameworksDropDown: selectedFrameworks, selectedBenchmarks, sortKey, displayMode, compareWith, categories }: State) {
103+
function updateResultTable({ frameworks, benchmarks, selectedFrameworksDropDown: selectedFrameworks, selectedBenchmarks, sortKey, displayMode, compareWith, categories, cpuDurationMode }: State) {
94104
return {
95-
[FrameworkType.KEYED]: new ResultTableData(frameworks, benchmarks, resultLookup, selectedFrameworks, selectedBenchmarks, FrameworkType.KEYED, sortKey, displayMode, compareWith[FrameworkType.KEYED], categories),
96-
[FrameworkType.NON_KEYED]: new ResultTableData(frameworks, benchmarks, resultLookup, selectedFrameworks, selectedBenchmarks, FrameworkType.NON_KEYED, sortKey, displayMode, compareWith[FrameworkType.NON_KEYED], categories)
105+
[FrameworkType.KEYED]: new ResultTableData(frameworks, benchmarks, resultLookup, selectedFrameworks, selectedBenchmarks, FrameworkType.KEYED, sortKey, displayMode, compareWith[FrameworkType.KEYED], categories, cpuDurationMode),
106+
[FrameworkType.NON_KEYED]: new ResultTableData(frameworks, benchmarks, resultLookup, selectedFrameworks, selectedBenchmarks, FrameworkType.NON_KEYED, sortKey, displayMode, compareWith[FrameworkType.NON_KEYED], categories, cpuDurationMode)
97107
}
98108
}
99109

@@ -123,7 +133,7 @@ function extractState(state: any): Partial<State> {
123133
}
124134
if (state.categories!==undefined) {
125135
const newSelectedCategories = new Set<number>();
126-
for (const f of state?.categories) {
136+
for (const f of state?.categories ?? []) {
127137
for (const sc of categories) {
128138
if (f === sc.id) newSelectedCategories.add(sc.id);
129139
}
@@ -192,6 +202,10 @@ interface SelectDisplayModeAction { type: 'SELECT_DISPLAYMODE'; data: { displayM
192202
export const selectDisplayMode = (displayMode: DisplayMode): SelectDisplayModeAction => {
193203
return { type: 'SELECT_DISPLAYMODE', data: { displayMode } }
194204
}
205+
interface SelectCpuDurationModeAction { type: 'SELECT_CPUDURATIONMODE'; data: { cpuDurationMode: CpuDurationMode } }
206+
export const selectCpuDurationMode = (cpuDurationMode: CpuDurationMode): SelectCpuDurationModeAction => {
207+
return { type: 'SELECT_CPUDURATIONMODE', data: { cpuDurationMode } }
208+
}
195209

196210
interface CompareAction { type: 'COMPARE'; data: { framework: Framework } }
197211
export const compare = (framework: Framework): CompareAction => {
@@ -217,7 +231,7 @@ export const setStateFromClipboard = (state: any): SetStateFromClipboardAction =
217231

218232
type Action = SelectFrameworkAction | SelectAllFrameworksAction | SelectBenchmarkAction | SelectAllBenchmarksAction
219233
| SelectDisplayModeAction | CompareAction | StopCompareAction | SortAction
220-
| SelectCategoryAction | SelectAllCategoriesAction | SetStateFromClipboardAction;
234+
| SelectCategoryAction | SelectAllCategoriesAction | SetStateFromClipboardAction | SelectCpuDurationModeAction;
221235

222236
export const reducer = (state = initialState, action: Action): State => {
223237
console.log("reducer", action)
@@ -267,6 +281,10 @@ export const reducer = (state = initialState, action: Action): State => {
267281
const t = { ...state, displayMode: action.data.displayMode };
268282
return { ...t, resultTables: updateResultTable(t) };
269283
}
284+
case 'SELECT_CPUDURATIONMODE': {
285+
const t = { ...state, cpuDurationMode: action.data.cpuDurationMode };
286+
return { ...t, resultTables: updateResultTable(t) };
287+
}
270288
case 'COMPARE': {
271289
const compareWith = { ...state.compareWith };
272290
compareWith[action.data.framework.type] = action.data.framework;

0 commit comments

Comments
 (0)