Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Side by Side Diff: test/codegen/expect/BenchmarkBase/BenchmarkBase.js

Issue 968273002: Fixing layout in js output (use full paths rather than just the library name) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var BenchmarkBase;
2 (function(BenchmarkBase) {
3 'use strict';
4 class Expect extends dart.Object {
5 static equals(expected, actual) {
6 if (!dart.equals(expected, actual)) {
7 throw `Values not equal: ${expected} vs ${actual}`;
8 }
9 }
10 static listEquals(expected, actual) {
11 if (expected.length !== actual.length) {
12 throw `Lists have different lengths: ${expected.length} vs ${actual.leng th}`;
13 }
14 for (let i = 0; i < actual.length; i++) {
15 equals(expected.get(i), actual.get(i));
16 }
17 }
18 fail(message) {
19 throw message;
20 }
21 }
22 class BenchmarkBase extends dart.Object {
23 BenchmarkBase(name) {
24 this.name = name;
25 }
26 run() {}
27 warmup() {
28 this.run();
29 }
30 exercise() {
31 for (let i = 0; i < 10; i++) {
32 this.run();
33 }
34 }
35 setup() {}
36 teardown() {}
37 static measureFor(f, timeMinimum) {
38 let time = 0;
39 let iter = 0;
40 let watch = new core.Stopwatch();
41 watch.start();
42 let elapsed = 0;
43 while (elapsed < timeMinimum) {
44 dart.dinvokef(f);
45 elapsed = watch.elapsedMilliseconds;
46 iter++;
47 }
48 return 1000.0 * elapsed / iter;
49 }
50 measure() {
51 this.setup();
52 measureFor((() => {
53 this.warmup();
54 }).bind(this), 100);
55 let result = measureFor((() => {
56 this.exercise();
57 }).bind(this), 2000);
58 this.teardown();
59 return result;
60 }
61 report() {
62 let score = this.measure();
63 core.print(`${this.name}(RunTime): ${score} us.`);
64 }
65 }
66 // Exports:
67 BenchmarkBase.Expect = Expect;
68 BenchmarkBase.BenchmarkBase = BenchmarkBase;
69 })(BenchmarkBase || (BenchmarkBase = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698