Skip to content

Commit f49c00b

Browse files
authored
Remove parsing time from benchmark and support comparing to a baseline. (#1389)
I'm trying to make it easier to see relative improvements in the benchmarks, so this change: * Moves the parsing outside of the main benchmark loop. Since that's all analyzer, there's nothing we can do about it, and it doesn't help to measure it for the formatter. This means the benchmark time doesn't reflect the total time spent doing work, but it means a relative improvement in formatting time will make a larger fractional change in the overall benchmark time. The formatter's public API doesn't have any way to pass in a parsed CompilationUnit and format it, so to get this working, I had to reimplement some of the parsing and formatting behavior from the DartFormatter class in run.dart. I simplified it down to just the bare minimum needed for benchmarks. In particular, I didn't bother supporting parsing and formatting a single statement. Instead, I just converted all of the benchmarks to be complete compilation units. * Adds support for showing benchmark output relative to some previously calculated baseline time. This makes it easier to see "this is 10% faster" without having to do math in my head. * Calculates time with higher precision. I'm not sure how much of a difference it makes, but I used microseconds and another significant digit.
1 parent 317cb1f commit f49c00b

22 files changed

+931
-1020
lines changed

benchmark/case/block.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test statements nested within blocks.
2-
{
2+
main() {
33
{
44
someLongOuterExpression +
55
anotherOperand;
@@ -76,4 +76,4 @@
7676
someLongOuterExpression +
7777
anotherOperand;
7878
}
79-
}
79+
}

benchmark/case/block.expect_short

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test statements nested within blocks.
2-
{
2+
main() {
33
{
44
someLongOuterExpression +
55
anotherOperand;
@@ -76,4 +76,4 @@
7676
someLongOuterExpression +
7777
anotherOperand;
7878
}
79-
}
79+
}

benchmark/case/block.stmt renamed to benchmark/case/block.unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
40 columns |
22
// Test statements nested within blocks.
3-
{
3+
main() {
44
{
55
someLongOuterExpression + anotherOperand;
66
someLongOuterExpression + anotherOperand;

benchmark/case/chain.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test long split method chains.
2-
target
2+
var result = target
33
.someMethod1(
44
argument1,
55
argument2,
@@ -99,4 +99,4 @@ target
9999
argument1,
100100
argument2,
101101
argument3,
102-
);
102+
);

benchmark/case/chain.expect_short

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test long split method chains.
2-
target
2+
var result = target
33
.someMethod1(
44
argument1, argument2, argument3)
55
.someMethod2(
@@ -39,4 +39,4 @@ target
3939
.someMethod19(
4040
argument1, argument2, argument3)
4141
.someMethod20(argument1, argument2,
42-
argument3);
42+
argument3);

benchmark/case/chain.stmt renamed to benchmark/case/chain.unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
40 columns |
22
// Test long split method chains.
3-
target
3+
var result = target
44
.someMethod1(argument1, argument2, argument3)
55
.someMethod2(argument1, argument2, argument3)
66
.someMethod3(argument1, argument2, argument3)

benchmark/case/collection.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test collection literals.
2-
[
2+
var list = [
33
[
44
[
55
listElement1,
@@ -124,4 +124,4 @@
124124
name2: recordField2,
125125
),
126126
),
127-
];
127+
];

benchmark/case/collection.expect_short

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test collection literals.
2-
[
2+
var list = [
33
[
44
[
55
listElement1,
@@ -124,4 +124,4 @@
124124
name2: recordField2
125125
),
126126
),
127-
];
127+
];

benchmark/case/collection.stmt renamed to benchmark/case/collection.unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
40 columns |
22
// Test collection literals.
3-
[
3+
var list = [
44
[
55
[listElement1, listElement2, listElement3],
66
{setElement1, setElement2, setElement3},

benchmark/case/collection_large.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test collection literals.
2-
[
2+
var list = [
33
[
44
[
55
[
@@ -508,4 +508,4 @@
508508
),
509509
),
510510
),
511-
];
511+
];

0 commit comments

Comments
 (0)