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

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

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
1 dart_library.library('BenchmarkBase', null, /* Imports */[ 1 dart_library.library('BenchmarkBase', null, /* Imports */[
2 'dart/_runtime', 2 'dart_sdk'
3 'dart/core' 3 ], function(exports, dart_sdk) {
4 ], /* Lazy imports */[
5 ], function(exports, dart, core) {
6 'use strict'; 4 'use strict';
7 let dartx = dart.dartx; 5 const core = dart_sdk.core;
8 class Expect extends core.Object { 6 const dart = dart_sdk.dart;
7 const dartx = dart_sdk.dartx;
8 const BenchmarkBase$ = Object.create(null);
9 BenchmarkBase$.Expect = class Expect extends core.Object {
9 static equals(expected, actual) { 10 static equals(expected, actual) {
10 if (!dart.equals(expected, actual)) { 11 if (!dart.equals(expected, actual)) {
11 dart.throw(`Values not equal: ${expected} vs ${actual}`); 12 dart.throw(`Values not equal: ${expected} vs ${actual}`);
12 } 13 }
13 } 14 }
14 static listEquals(expected, actual) { 15 static listEquals(expected, actual) {
15 if (expected[dartx.length] != actual[dartx.length]) { 16 if (expected[dartx.length] != actual[dartx.length]) {
16 dart.throw(`Lists have different lengths: ${expected[dartx.length]} vs $ {actual[dartx.length]}`); 17 dart.throw(`Lists have different lengths: ${expected[dartx.length]} vs $ {actual[dartx.length]}`);
17 } 18 }
18 for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) { 19 for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) {
19 Expect.equals(expected[dartx.get](i), actual[dartx.get](i)); 20 BenchmarkBase$.Expect.equals(expected[dartx.get](i), actual[dartx.get](i ));
20 } 21 }
21 } 22 }
22 fail(message) { 23 fail(message) {
23 dart.throw(message); 24 dart.throw(message);
24 } 25 }
25 } 26 };
26 dart.setSignature(Expect, { 27 dart.setSignature(BenchmarkBase$.Expect, {
27 methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}), 28 methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}),
28 statics: () => ({ 29 statics: () => ({
29 equals: [dart.void, [dart.dynamic, dart.dynamic]], 30 equals: [dart.void, [dart.dynamic, dart.dynamic]],
30 listEquals: [dart.void, [core.List, core.List]] 31 listEquals: [dart.void, [core.List, core.List]]
31 }), 32 }),
32 names: ['equals', 'listEquals'] 33 names: ['equals', 'listEquals']
33 }); 34 });
34 class BenchmarkBase extends core.Object { 35 BenchmarkBase$.BenchmarkBase = class BenchmarkBase extends core.Object {
35 BenchmarkBase(name) { 36 BenchmarkBase(name) {
36 this.name = name; 37 this.name = name;
37 } 38 }
38 run() {} 39 run() {}
39 warmup() { 40 warmup() {
40 this.run(); 41 this.run();
41 } 42 }
42 exercise() { 43 exercise() {
43 for (let i = 0; i < 10; i++) { 44 for (let i = 0; i < 10; i++) {
44 this.run(); 45 this.run();
45 } 46 }
46 } 47 }
47 setup() {} 48 setup() {}
48 teardown() {} 49 teardown() {}
49 static measureFor(f, timeMinimum) { 50 static measureFor(f, timeMinimum) {
50 let time = 0; 51 let time = 0;
51 let iter = 0; 52 let iter = 0;
52 let watch = new core.Stopwatch(); 53 let watch = new core.Stopwatch();
53 watch.start(); 54 watch.start();
54 let elapsed = 0; 55 let elapsed = 0;
55 while (dart.notNull(elapsed) < dart.notNull(timeMinimum)) { 56 while (dart.notNull(elapsed) < dart.notNull(timeMinimum)) {
56 dart.dcall(f); 57 dart.dcall(f);
57 elapsed = watch.elapsedMilliseconds; 58 elapsed = watch.elapsedMilliseconds;
58 iter++; 59 iter++;
59 } 60 }
60 return 1000.0 * dart.notNull(elapsed) / iter; 61 return 1000.0 * dart.notNull(elapsed) / iter;
61 } 62 }
62 measure() { 63 measure() {
63 this.setup(); 64 this.setup();
64 BenchmarkBase.measureFor(dart.fn(() => { 65 BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => {
65 this.warmup(); 66 this.warmup();
66 }), 100); 67 }), 100);
67 let result = BenchmarkBase.measureFor(dart.fn(() => { 68 let result = BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => {
68 this.exercise(); 69 this.exercise();
69 }), 2000); 70 }), 2000);
70 this.teardown(); 71 this.teardown();
71 return result; 72 return result;
72 } 73 }
73 report() { 74 report() {
74 let score = this.measure(); 75 let score = this.measure();
75 core.print(`${this.name}(RunTime): ${score} us.`); 76 core.print(`${this.name}(RunTime): ${score} us.`);
76 } 77 }
77 } 78 };
78 dart.setSignature(BenchmarkBase, { 79 dart.setSignature(BenchmarkBase$.BenchmarkBase, {
79 constructors: () => ({BenchmarkBase: [BenchmarkBase, [core.String]]}), 80 constructors: () => ({BenchmarkBase: [BenchmarkBase$.BenchmarkBase, [core.St ring]]}),
80 methods: () => ({ 81 methods: () => ({
81 run: [dart.void, []], 82 run: [dart.void, []],
82 warmup: [dart.void, []], 83 warmup: [dart.void, []],
83 exercise: [dart.void, []], 84 exercise: [dart.void, []],
84 setup: [dart.void, []], 85 setup: [dart.void, []],
85 teardown: [dart.void, []], 86 teardown: [dart.void, []],
86 measure: [core.double, []], 87 measure: [core.double, []],
87 report: [dart.void, []] 88 report: [dart.void, []]
88 }), 89 }),
89 statics: () => ({measureFor: [core.double, [core.Function, core.int]]}), 90 statics: () => ({measureFor: [core.double, [core.Function, core.int]]}),
90 names: ['measureFor'] 91 names: ['measureFor']
91 }); 92 });
92 // Exports: 93 // Exports:
93 exports.Expect = Expect; 94 exports.BenchmarkBase = BenchmarkBase$;
94 exports.BenchmarkBase = BenchmarkBase;
95 }); 95 });
OLDNEW
« no previous file with comments | « test/codegen/expect/8invalid-chars.in+file_name.txt ('k') | test/codegen/expect/BenchmarkBase.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698