Stopwatch is slower than window.performance.now() when compiled to JavaScript #9584
Labels
closed-obsolete
Closed as the reported issue is no longer relevant
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
web-dart2js
Consider these two benchmarks:
class PerfNowBenchmark extends BenchmarkBase {
const PerfNowBenchmark() : super("PerfNow");
// The benchmark code.
void run() {
var time = window.performance.now();
}
}
class StopwatchBenchmark extends BenchmarkBase {
Stopwatch sw;
StopwatchBenchmark() : super("Stopwatch") {
sw = new Stopwatch()..start();
}
// The benchmark code.
void run() {
var time = sw.elapsedMicroseconds;
}
}
(using the benchmark_harness package)
When run in Dartium:
PerfNow(RunTime): 6.421432172017325 us.
Stopwatch(RunTime): 4.861614153131122 us.
When run in dart2js:
PerfNow(RunTime): 3.4266818582895717 us.
Stopwatch(RunTime): 5.462122908689691 us.
Here is a simple main() to drive it:
import 'dart:html';
import 'package:benchmark_harness/benchmark_harness.dart';
void main() {
new PerfNowBenchmark().report();
new StopwatchBenchmark().report();
}
The text was updated successfully, but these errors were encountered: