Skip to content

Commit ea49037

Browse files
committed
run prettier, cleanup
1 parent adecb23 commit ea49037

23 files changed

+282
-495
lines changed

server/app.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import minifier from "html-minifier";
88
import { Stream } from "stream";
99
import toArray from "stream-to-array";
1010
import zlib from "node:zlib";
11-
import { pipeline } from "node:stream";
12-
import { promisify } from "node:util";
1311
import { getSizeRouter } from "./src/responseSize/responseSizeRouter.js";
1412

1513
/**
@@ -64,7 +62,7 @@ function buildServer(options = {}) {
6462
reply.header("Content-Length", compressed.length);
6563
reply.header("Content-Encoding", "br");
6664
}
67-
let headers = Object.entries(reply.getHeaders()).reduce((p, [e, v]) => p + `${e}: ${v} \n`, "");
65+
// let headers = Object.entries(reply.getHeaders()).reduce((p, [e, v]) => p + `${e}: ${v} \n`, "");
6866
// console.log(request.url, reply.statusCode, "\n", headers);
6967
return {
7068
compressed: compressed.length, // + headers.length + MISSING_HEADERS_AND_HTTP,

webdriver-ts/README.txt

Lines changed: 0 additions & 23 deletions
This file was deleted.

webdriver-ts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"test": "vitest --run",
1818
"test:watch": "vitest",
1919
"coverage": "vitest --run --coverage",
20-
"lint": "eslint src/ --ext .ts"
2120
},
2221
"author": "",
2322
"license": "Apache-2.0",

webdriver-ts/src/benchmarkRunner.ts

Lines changed: 81 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,10 @@ function forkAndCallBenchmark(
5252
benchmarkId: benchmarkInfo.id,
5353
benchmarkOptions,
5454
});
55-
forked.on(
56-
"message",
57-
(msg: ErrorAndWarning<number | CPUBenchmarkResult | StartupBenchmarkResult>) => {
55+
forked.on("message", (msg: ErrorAndWarning<number | CPUBenchmarkResult | StartupBenchmarkResult>) => {
5856
if (config.LOG_DETAILS) console.log("FORKING: main process got message from child", msg);
5957
resolve(msg);
60-
}
61-
);
58+
});
6259
forked.on("close", (msg) => {
6360
if (config.LOG_DETAILS) console.log("FORKING: child closed", msg);
6461
});
@@ -185,14 +182,14 @@ async function runBenchmakLoop(
185182
benchmark: benchmarkInfo,
186183
results: results as CPUBenchmarkResult[],
187184
type: BenchmarkType.CPU,
188-
});
185+
});
189186
} else {
190187
await writeResults(benchmarkOptions.resultsDirectory, {
191188
framework: framework,
192189
benchmark: benchmarkInfo,
193190
results: results as number[],
194191
type: BenchmarkType.MEM,
195-
});
192+
});
196193
}
197194
}
198195
return { errors, warnings };
@@ -231,11 +228,25 @@ async function runBench(
231228
let result;
232229

233230
if (benchmarkInfos[j].type == BenchmarkType.STARTUP_MAIN) {
234-
result = await runBenchmakLoopStartup(runFrameworks[i], benchmarkInfos[j] as StartupBenchmarkInfo, benchmarkOptions)
231+
result = await runBenchmakLoopStartup(
232+
runFrameworks[i],
233+
benchmarkInfos[j] as StartupBenchmarkInfo,
234+
benchmarkOptions
235+
);
235236
} else if (benchmarkInfos[j].type == BenchmarkType.CPU) {
236-
result = await runBenchmakLoop(runFrameworks[i], benchmarkInfos[j] as CPUBenchmarkInfo, benchmarkOptions, plausibilityCheck);
237+
result = await runBenchmakLoop(
238+
runFrameworks[i],
239+
benchmarkInfos[j] as CPUBenchmarkInfo,
240+
benchmarkOptions,
241+
plausibilityCheck
242+
);
237243
} else {
238-
result = await runBenchmakLoop(runFrameworks[i], benchmarkInfos[j] as MemBenchmarkInfo, benchmarkOptions, plausibilityCheck);
244+
result = await runBenchmakLoop(
245+
runFrameworks[i],
246+
benchmarkInfos[j] as MemBenchmarkInfo,
247+
benchmarkOptions,
248+
plausibilityCheck
249+
);
239250
}
240251
errors = errors.concat(result.errors);
241252
warnings = warnings.concat(result.warnings);
@@ -271,34 +282,34 @@ async function runBench(
271282
}
272283

273284
async function main() {
274-
// FIXME: Clean up args.
275-
// What works: npm run bench keyed/react, npm run bench -- keyed/react, npm run bench -- keyed/react --count 1 --benchmark 01_
276-
// What doesn't work (keyed/react becomes an element of argument benchmark): npm run bench -- --count 1 --benchmark 01_ keyed/react
285+
// FIXME: Clean up args.
286+
// What works: npm run bench keyed/react, npm run bench -- keyed/react, npm run bench -- keyed/react --count 1 --benchmark 01_
287+
// What doesn't work (keyed/react becomes an element of argument benchmark): npm run bench -- --count 1 --benchmark 01_ keyed/react
277288

278289
console.error("PLEASE MAKE SURE THAT YOUR MOUSE IS OUTSIDE OF THE BROWSER WINDOW - and sorry for shouting :-) ");
279290

280-
let args: any = yargs(process.argv)
281-
.usage(
282-
"$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]"
283-
)
284-
.help("help")
291+
let args: any = yargs(process.argv)
292+
.usage(
293+
"$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]"
294+
)
295+
.help("help")
285296
.boolean("headless")
286297
.default("headless", false)
287-
.boolean("smoketest")
298+
.boolean("smoketest")
288299
.boolean("nothrottling")
289300
.default("nothrottling", false)
290301
.string("runner")
291302
.default("runner", "puppeteer")
292303
.string("browser")
293304
.default("browser", "chrome")
294-
.array("framework")
295-
.array("benchmark")
296-
.number("count")
297-
.string("chromeBinary").argv;
305+
.array("framework")
306+
.array("benchmark")
307+
.number("count")
308+
.string("chromeBinary").argv;
298309

299-
console.log("args", args);
310+
console.log("args", args);
300311

301-
let runner = args.runner;
312+
let runner = args.runner;
302313
if (
303314
[
304315
BenchmarkRunner.WEBDRIVER_CDP,
@@ -309,64 +320,61 @@ let runner = args.runner;
309320
].includes(runner)
310321
) {
311322
console.log(`INFO: Using ${runner} benchmark runner`);
312-
config.BENCHMARK_RUNNER = runner;
313-
} else {
323+
config.BENCHMARK_RUNNER = runner;
324+
} else {
314325
console.log("ERROR: argument driver has illegal value " + runner, [
315326
BenchmarkRunner.WEBDRIVER_CDP,
316327
BenchmarkRunner.WEBDRIVER,
317328
BenchmarkRunner.PLAYWRIGHT,
318329
BenchmarkRunner.PUPPETEER,
319330
]);
320-
process.exit(1);
321-
}
322-
console.log("HEADLESS*** ", args.headless);
323-
324-
let benchmarkOptions: BenchmarkOptions = {
325-
port: 8080,
326-
host: "localhost",
327-
browser: args.browser,
328-
remoteDebuggingPort: 9999,
329-
chromePort: 9998,
330-
headless: args.headless,
331-
chromeBinaryPath: args.chromeBinary,
332-
numIterationsForCPUBenchmarks:
333-
config.NUM_ITERATIONS_FOR_BENCHMARK_CPU +
334-
config.NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT,
335-
numIterationsForMemBenchmarks: config.NUM_ITERATIONS_FOR_BENCHMARK_MEM,
336-
numIterationsForStartupBenchmark: config.NUM_ITERATIONS_FOR_BENCHMARK_STARTUP,
337-
batchSize: 1,
338-
resultsDirectory: "results",
339-
tracesDirectory: "traces",
340-
allowThrottling: !args.nothrottling,
341-
};
342-
343-
if (args.count) {
344-
benchmarkOptions.numIterationsForCPUBenchmarks = args.count;
345-
config.NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT = 0;
346-
benchmarkOptions.numIterationsForMemBenchmarks = args.count;
347-
benchmarkOptions.numIterationsForStartupBenchmark = args.count;
348-
}
331+
process.exit(1);
332+
}
333+
console.log("HEADLESS*** ", args.headless);
334+
335+
let benchmarkOptions: BenchmarkOptions = {
336+
port: 8080,
337+
host: "localhost",
338+
browser: args.browser,
339+
remoteDebuggingPort: 9999,
340+
chromePort: 9998,
341+
headless: args.headless,
342+
chromeBinaryPath: args.chromeBinary,
343+
numIterationsForCPUBenchmarks:
344+
config.NUM_ITERATIONS_FOR_BENCHMARK_CPU + config.NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT,
345+
numIterationsForMemBenchmarks: config.NUM_ITERATIONS_FOR_BENCHMARK_MEM,
346+
numIterationsForStartupBenchmark: config.NUM_ITERATIONS_FOR_BENCHMARK_STARTUP,
347+
batchSize: 1,
348+
resultsDirectory: "results",
349+
tracesDirectory: "traces",
350+
allowThrottling: !args.nothrottling,
351+
};
352+
353+
if (args.count) {
354+
benchmarkOptions.numIterationsForCPUBenchmarks = args.count;
355+
config.NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT = 0;
356+
benchmarkOptions.numIterationsForMemBenchmarks = args.count;
357+
benchmarkOptions.numIterationsForStartupBenchmark = args.count;
358+
}
349359

350-
let allArgs = args._.length <= 2 ? [] : args._.slice(2, args._.length);
351-
let frameworkArgument = !args.framework ? allArgs : args.framework;
352-
console.log("args", args, "allArgs", allArgs);
360+
let allArgs = args._.length <= 2 ? [] : args._.slice(2, args._.length);
361+
let frameworkArgument = !args.framework ? allArgs : args.framework;
362+
console.log("args", args, "allArgs", allArgs);
353363

354-
if (process.env.HOST) {
355-
benchmarkOptions.host = process.env.HOST;
356-
console.log(`INFO: Using host ${benchmarkOptions.host} instead of localhost`);
357-
}
358-
console.log("benchmarkOptions", benchmarkOptions);
364+
if (process.env.HOST) {
365+
benchmarkOptions.host = process.env.HOST;
366+
console.log(`INFO: Using host ${benchmarkOptions.host} instead of localhost`);
367+
}
368+
console.log("benchmarkOptions", benchmarkOptions);
359369

360-
let runBenchmarksArgs: string[] =
361-
args.benchmark && args.benchmark.length > 0 ? args.benchmark : [""];
370+
let runBenchmarksArgs: string[] = args.benchmark && args.benchmark.length > 0 ? args.benchmark : [""];
362371
let runBenchmarks: Array<BenchmarkInfo> = benchmarkInfos.filter(
363372
(b) =>
364373
// afterframe currently only targets CPU benchmarks
365-
(config.BENCHMARK_RUNNER !== BenchmarkRunner.WEBDRIVER_AFTERFRAME ||
366-
b.type == BenchmarkType.CPU) &&
367-
runBenchmarksArgs.some((name) => b.id.toLowerCase().indexOf(name) > -1)
374+
(config.BENCHMARK_RUNNER !== BenchmarkRunner.WEBDRIVER_AFTERFRAME || b.type == BenchmarkType.CPU) &&
375+
runBenchmarksArgs.some((name) => b.id.toLowerCase().indexOf(name) > -1)
368376
);
369-
377+
370378
let runFrameworks: FrameworkData[];
371379
let matchesDirectoryArg = (directoryName: string) =>
372380
frameworkArgument.length == 0 || frameworkArgument.some((arg: string) => arg == directoryName);
@@ -389,11 +397,9 @@ console.log("benchmarkOptions", benchmarkOptions);
389397
}
390398
if (config.BENCHMARK_RUNNER == BenchmarkRunner.WEBDRIVER_AFTERFRAME) {
391399
benchmarkOptions.resultsDirectory = "results_client_" + benchmarkOptions.browser;
392-
}
393-
if (!fs.existsSync(benchmarkOptions.resultsDirectory))
394-
fs.mkdirSync(benchmarkOptions.resultsDirectory);
395-
if (!fs.existsSync(benchmarkOptions.tracesDirectory))
396-
fs.mkdirSync(benchmarkOptions.tracesDirectory);
400+
}
401+
if (!fs.existsSync(benchmarkOptions.resultsDirectory)) fs.mkdirSync(benchmarkOptions.resultsDirectory);
402+
if (!fs.existsSync(benchmarkOptions.tracesDirectory)) fs.mkdirSync(benchmarkOptions.tracesDirectory);
397403

398404
if (args.help) {
399405
// yargs.showHelp();

webdriver-ts/src/benchmarksCommon.ts

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ export interface StartupBenchmarkInfo extends BenchmarkInfoBase {
3535
fn: (x: number) => number;
3636
}
3737

38-
export type BenchmarkInfo =
39-
| CPUBenchmarkInfo
40-
| MemBenchmarkInfo
41-
| StartupMainBenchmarkInfo
42-
| StartupBenchmarkInfo;
38+
export type BenchmarkInfo = CPUBenchmarkInfo | MemBenchmarkInfo | StartupMainBenchmarkInfo | StartupBenchmarkInfo;
4339

4440
export interface BenchmarkImpl {
4541
benchmarkInfo: BenchmarkInfo;
@@ -118,10 +114,7 @@ export const cpuBenchmarkInfosArray: Array<CPUBenchmarkInfo> = [
118114
id: Benchmark._02,
119115
label: "replace all rows",
120116
description: (throttleCPU: number | undefined) =>
121-
"updating all 1,000 rows (" +
122-
config.WARMUP_COUNT +
123-
" warmup runs)." +
124-
slowDownNote(throttleCPU),
117+
"updating all 1,000 rows (" + config.WARMUP_COUNT + " warmup runs)." + slowDownNote(throttleCPU),
125118
type: BenchmarkType.CPU,
126119
allowBatching: true,
127120
layoutEventRequired: true,
@@ -141,10 +134,7 @@ export const cpuBenchmarkInfosArray: Array<CPUBenchmarkInfo> = [
141134
id: Benchmark._04,
142135
label: "select row",
143136
description: (throttleCPU: number | undefined) =>
144-
"highlighting a selected row. (" +
145-
config.WARMUP_COUNT +
146-
" warmup runs)." +
147-
slowDownNote(throttleCPU),
137+
"highlighting a selected row. (" + config.WARMUP_COUNT + " warmup runs)." + slowDownNote(throttleCPU),
148138
type: BenchmarkType.CPU,
149139
allowBatching: true,
150140
layoutEventRequired: false,
@@ -154,10 +144,7 @@ export const cpuBenchmarkInfosArray: Array<CPUBenchmarkInfo> = [
154144
id: Benchmark._05,
155145
label: "swap rows",
156146
description: (throttleCPU: number | undefined) =>
157-
"swap 2 rows for table with 1,000 rows. (" +
158-
config.WARMUP_COUNT +
159-
" warmup runs)." +
160-
slowDownNote(throttleCPU),
147+
"swap 2 rows for table with 1,000 rows. (" + config.WARMUP_COUNT + " warmup runs)." + slowDownNote(throttleCPU),
161148
type: BenchmarkType.CPU,
162149
allowBatching: true,
163150
layoutEventRequired: true,
@@ -177,10 +164,7 @@ export const cpuBenchmarkInfosArray: Array<CPUBenchmarkInfo> = [
177164
id: Benchmark._07,
178165
label: "create many rows",
179166
description: (throttleCPU: number | undefined) =>
180-
"creating 10,000 rows. (" +
181-
config.WARMUP_COUNT +
182-
" warmup runs with 1k rows)." +
183-
slowDownNote(throttleCPU),
167+
"creating 10,000 rows. (" + config.WARMUP_COUNT + " warmup runs with 1k rows)." + slowDownNote(throttleCPU),
184168
type: BenchmarkType.CPU,
185169
allowBatching: true,
186170
layoutEventRequired: true,
@@ -200,11 +184,7 @@ export const cpuBenchmarkInfosArray: Array<CPUBenchmarkInfo> = [
200184
id: Benchmark._09,
201185
label: "clear rows",
202186
description: (throttleCPU: number | undefined) =>
203-
"clearing a table with 1,000 rows." +
204-
slowDownNote(throttleCPU) +
205-
" (" +
206-
config.WARMUP_COUNT +
207-
" warmup runs).",
187+
"clearing a table with 1,000 rows." + slowDownNote(throttleCPU) + " (" + config.WARMUP_COUNT + " warmup runs).",
208188
type: BenchmarkType.CPU,
209189
allowBatching: true,
210190
layoutEventRequired: true,
@@ -275,8 +255,4 @@ for (let bi of startupBenchmarkInfosArray) {
275255
startupBenchmarkInfos[bi.id] = bi;
276256
}
277257

278-
export const benchmarkInfos = [
279-
...cpuBenchmarkInfosArray,
280-
...memBenchmarkInfosArray,
281-
...startupBenchmarkInfosArray,
282-
];
258+
export const benchmarkInfos = [...cpuBenchmarkInfosArray, ...memBenchmarkInfosArray, ...startupBenchmarkInfosArray];

webdriver-ts/src/benchmarksLighthouse.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ let toKb = (x: number) => x / 1024;
1212
export const benchStartupConsistentlyInteractive: StartupBenchmarkInfo = {
1313
id: "31_startup-ci",
1414
label: "consistently interactive",
15-
description: () => "a pessimistic TTI - when the CPU and network are both definitely very idle. (no more CPU tasks over 50ms)",
15+
description: () =>
16+
"a pessimistic TTI - when the CPU and network are both definitely very idle. (no more CPU tasks over 50ms)",
1617
property: "interactive",
1718
fn: id,
1819
type: BenchmarkType.STARTUP,

0 commit comments

Comments
 (0)