Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopwatch is slower than window.performance.now() when compiled to JavaScript #9584

Closed
sethladd opened this issue Apr 2, 2013 · 5 comments
Closed
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

Comments

@sethladd
Copy link
Contributor

sethladd commented Apr 2, 2013

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();
}

@kasperl
Copy link

kasperl commented Apr 22, 2013

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented May 23, 2013

Added TriageForM5 label.

@kasperl
Copy link

kasperl commented May 28, 2013

Removed TriageForM5 label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Feb 29, 2016
@munificent munificent removed the C2 label Jun 20, 2018
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

5 participants