Skip to content

Commit 09324da

Browse files
committed
Add config.measureValue callback
config.measureValue is call with the elapsed time in milliseconds for every measurement. This is intended to be used in Chromium Performance Test. [email protected] Review URL: https://codereview.appspot.com/141390043
1 parent 5471e10 commit 09324da

7 files changed

+23
-0
lines changed

src/example/benchmark.html

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
} else {
6868
config.addToLog = addToLog;
6969
config.addToSummary = addToSummary;
70+
config.measureValue = measureValue;
7071
sendBenchmark(config);
7172
}
7273
}
@@ -79,6 +80,7 @@
7980
} else {
8081
config.addToLog = addToLog;
8182
config.addToSummary = addToSummary;
83+
config.measureValue = measureValue;
8284
receiveBenchmark(config);
8385
}
8486
}
@@ -91,6 +93,7 @@
9193
} else {
9294
config.addToLog = addToLog;
9395
config.addToSummary = addToSummary;
96+
config.measureValue = measureValue;
9497
batchBenchmark(config);
9598
}
9699
}
@@ -103,6 +106,7 @@
103106
} else {
104107
config.addToLog = addToLog;
105108
config.addToSummary = addToSummary;
109+
config.measureValue = measureValue;
106110
stop(config);
107111
}
108112
}

src/example/benchmark.js

+1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ onmessage = function (message) {
276276
var config = message.data.config;
277277
config.addToLog = workerAddToLog;
278278
config.addToSummary = workerAddToSummary;
279+
config.measureValue = workerMeasureValue;
279280
if (message.data.type === 'sendBenchmark')
280281
sendBenchmark(config);
281282
else if (message.data.type === 'receiveBenchmark')

src/example/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function calculateAndLogResult(config, size, startTimeInMs, totalSize) {
8383
if (!results[size]) {
8484
results[size] = {n: 0, sum_t: 0, sum_t2: 0};
8585
}
86+
config.measureValue(timePerMessageInMs);
8687
results[size].n ++;
8788
results[size].sum_t += timePerMessageInMs;
8889
results[size].sum_t2 += timePerMessageInMs * timePerMessageInMs;

src/example/util_main.js

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ function addToSummary(log) {
2727
summaryBox.scrollTop = 1000000;
2828
}
2929

30+
// value: execution time in milliseconds.
31+
// config.measureValue is intended to be used in Performance Tests.
32+
// Do nothing here in non-PerformanceTest.
33+
function measureValue(value) {
34+
}
35+
3036
function getIntFromInput(id) {
3137
return parseInt(document.getElementById(id).value);
3238
}
@@ -52,4 +58,6 @@ function onMessage(message) {
5258
addToLog(message.data.data);
5359
else if (message.data.type === 'addToSummary')
5460
addToSummary(message.data.data);
61+
else if (message.data.type === 'measureValue')
62+
measureValue(message.data.data);
5563
}

src/example/util_worker.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ function workerAddToLog(text) {
1313
function workerAddToSummary(text) {
1414
postMessage({type: 'addToSummary', data: text});
1515
}
16+
17+
function workerMeasureValue(value) {
18+
postMessage({type: 'measureValue', data: value});
19+
}

src/example/xhr_benchmark.html

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
} else {
7070
config.addToLog = addToLog;
7171
config.addToSummary = addToSummary;
72+
config.measureValue = measureValue;
7273
sendBenchmark(config);
7374
}
7475
}
@@ -82,6 +83,7 @@
8283
} else {
8384
config.addToLog = addToLog;
8485
config.addToSummary = addToSummary;
86+
config.measureValue = measureValue;
8587
receiveBenchmark(config);
8688
}
8789
}
@@ -94,6 +96,7 @@
9496
} else {
9597
config.addToLog = addToLog;
9698
config.addToSummary = addToSummary;
99+
config.measureValue = measureValue;
97100
batchBenchmark(config);
98101
}
99102
}
@@ -106,6 +109,7 @@
106109
} else {
107110
config.addToLog = addToLog;
108111
config.addToSummary = addToSummary;
112+
config.measureValue = measureValue;
109113
stop(config);
110114
}
111115
}

src/example/xhr_benchmark.js

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ onmessage = function (message) {
346346
var config = message.data.config;
347347
config.addToLog = workerAddToLog;
348348
config.addToSummary = workerAddToSummary;
349+
config.measureValue = workerMeasureValue;
349350
if (message.data.type === 'sendBenchmark')
350351
sendBenchmark(config);
351352
else if (message.data.type === 'receiveBenchmark')

0 commit comments

Comments
 (0)