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

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

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

Powered by Google App Engine
This is Rietveld 408576698