Skip to content

Commit

Permalink
Use milliseconds in perf benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Oct 13, 2017
1 parent daa0957 commit 13f30bf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions tools/perf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Perf testing
Measure the performance impact of changes that you make to the fluent.js
codebase.

Execution time is reported in microseconds (μs).
Execution time is reported in milliseconds (ms).

The script measures the speed of parsing, compilation and getting all entities
from a resource file based on Firefox OS's [Settings localization file][]. The
Expand Down Expand Up @@ -65,7 +65,7 @@ significant, it will be show in green (faster) or red (slower).
High Resolution Timer (HRT)
---------------------------

All numbers are reported in microseconds (μs) via node's
All numbers are reported in millisecods (ms) via node's
[process.hrtime][] or SpiderMonkey shell's [dateNow][]. This allows to
measure the time of a single operation.

Expand Down
12 changes: 6 additions & 6 deletions tools/perf/benchmark.d8.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ load('../../fluent-syntax/fluent-syntax.js');
var ftlCode = read('./workload-low.ftl');
var args = {}

function micro(time) {
// time is in milliseconds
return Math.round(time * 1000);
function ms(time) {
// time is in milliseconds with decimals
return Math.round(time * 1e3) / 1e3;
}

var times = {};
Expand Down Expand Up @@ -34,9 +34,9 @@ for (const [id, message] of ctx.messages) {
times.formatEnd = Date.now();

var results = {
parseFTL: micro(times.ftlParseEnd - times.ftlParseStart),
parseFTLEntries: micro(times.ftlEntriesParseEnd - times.ftlEntriesParseStart),
format: micro(times.formatEnd - times.format),
"parse full AST (ms)": ms(times.ftlParseEnd - times.ftlParseStart),
"parse runtime AST (ms)": ms(times.ftlEntriesParseEnd - times.ftlEntriesParseStart),
"format (ms)": ms(times.formatEnd - times.format),
};

print(JSON.stringify(results));
10 changes: 5 additions & 5 deletions tools/perf/benchmark.jsshell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ load('../../fluent-syntax/fluent-syntax.js');
var ftlCode = read('./workload-low.ftl');
var args = {};

function micro(time) {
function ms(time) {
// time is in milliseconds with decimals
return Math.round(time * 1000);
return Math.round(time * 1e3) / 1e3;
}

var times = {};
Expand Down Expand Up @@ -34,9 +34,9 @@ for (const [id, message] of ctx.messages) {
times.formatEnd = dateNow();

var results = {
parseFTL: micro(times.ftlParseEnd - times.ftlParseStart),
parseFTLEntries: micro(times.ftlEntriesParseEnd - times.ftlEntriesParseStart),
format: micro(times.formatEnd - times.format),
"parse full AST (ms)": ms(times.ftlParseEnd - times.ftlParseStart),
"parse runtime AST (ms)": ms(times.ftlEntriesParseEnd - times.ftlEntriesParseStart),
"format (ms)": ms(times.formatEnd - times.format),
};

print(JSON.stringify(results));
11 changes: 5 additions & 6 deletions tools/perf/benchmark.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ var ftlCode = fs.readFileSync(__dirname + '/workload-low.ftl').toString();

var args = {};

function micro(time) {
// time is [seconds, nanoseconds]
return Math.round((time[0] * 1e9 + time[1]) / 1000);
function ms([seconds, nanoseconds]) {
return Math.round((seconds * 1e9 + nanoseconds) / 1e3) / 1e3;
}

var cumulative = {};
Expand Down Expand Up @@ -39,8 +38,8 @@ for (const [id, message] of ctx.messages) {
cumulative.formatEnd = process.hrtime(start);

var results = {
parseFTL: micro(cumulative.ftlParseEnd) - micro(cumulative.ftlParseStart),
parseFTLEntries: micro(cumulative.ftlEntriesParseEnd) - micro(cumulative.ftlEntriesParseStart),
format: micro(cumulative.formatEnd) - micro(cumulative.format),
"parse full AST (ms)": ms(cumulative.ftlParseEnd) - ms(cumulative.ftlParseStart),
"parse runtime AST (ms)": ms(cumulative.ftlEntriesParseEnd) - ms(cumulative.ftlEntriesParseStart),
"format (ms)": ms(cumulative.formatEnd) - ms(cumulative.format),
};
console.log(JSON.stringify(results));

0 comments on commit 13f30bf

Please sign in to comment.