OLD | NEW |
1 dart_library.library('DeltaBlue', null, /* Imports */[ | 1 dart_library.library('DeltaBlue', null, /* Imports */[ |
2 'dart_sdk' | 2 'dart_sdk' |
3 ], function(exports, dart_sdk) { | 3 ], function(exports, dart_sdk) { |
4 'use strict'; | 4 'use strict'; |
5 const core = dart_sdk.core; | 5 const core = dart_sdk.core; |
6 const dart = dart_sdk.dart; | 6 const dart = dart_sdk.dart; |
7 const dartx = dart_sdk.dartx; | 7 const dartx = dart_sdk.dartx; |
8 const DeltaBlue$ = Object.create(null); | 8 const DeltaBlue$ = Object.create(null); |
9 const BenchmarkBase$ = Object.create(null); | 9 const BenchmarkBase$ = Object.create(null); |
10 DeltaBlue$.main = function() { | 10 DeltaBlue$.main = function() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 this.warmup(); | 45 this.warmup(); |
46 }), 100); | 46 }), 100); |
47 let result = BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => { | 47 let result = BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => { |
48 this.exercise(); | 48 this.exercise(); |
49 }), 2000); | 49 }), 2000); |
50 this.teardown(); | 50 this.teardown(); |
51 return result; | 51 return result; |
52 } | 52 } |
53 report() { | 53 report() { |
54 let score = this.measure(); | 54 let score = this.measure(); |
55 core.print(`${this.name}(RunTime): ${score} us.`); | 55 core.print(dart.str`${this.name}(RunTime): ${score} us.`); |
56 } | 56 } |
57 }; | 57 }; |
58 dart.setSignature(BenchmarkBase$.BenchmarkBase, { | 58 dart.setSignature(BenchmarkBase$.BenchmarkBase, { |
59 constructors: () => ({new: [BenchmarkBase$.BenchmarkBase, [core.String]]}), | 59 constructors: () => ({new: [BenchmarkBase$.BenchmarkBase, [core.String]]}), |
60 methods: () => ({ | 60 methods: () => ({ |
61 run: [dart.void, []], | 61 run: [dart.void, []], |
62 warmup: [dart.void, []], | 62 warmup: [dart.void, []], |
63 exercise: [dart.void, []], | 63 exercise: [dart.void, []], |
64 setup: [dart.void, []], | 64 setup: [dart.void, []], |
65 teardown: [dart.void, []], | 65 teardown: [dart.void, []], |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 prev = v; | 525 prev = v; |
526 } | 526 } |
527 new DeltaBlue$.StayConstraint(last, DeltaBlue$.STRONG_DEFAULT); | 527 new DeltaBlue$.StayConstraint(last, DeltaBlue$.STRONG_DEFAULT); |
528 let edit = new DeltaBlue$.EditConstraint(first, DeltaBlue$.PREFERRED); | 528 let edit = new DeltaBlue$.EditConstraint(first, DeltaBlue$.PREFERRED); |
529 let plan = DeltaBlue$.planner.extractPlanFromConstraints(dart.list([edit], D
eltaBlue$.Constraint)); | 529 let plan = DeltaBlue$.planner.extractPlanFromConstraints(dart.list([edit], D
eltaBlue$.Constraint)); |
530 for (let i = 0; i < 100; i++) { | 530 for (let i = 0; i < 100; i++) { |
531 first.value = i; | 531 first.value = i; |
532 plan.execute(); | 532 plan.execute(); |
533 if (last.value != i) { | 533 if (last.value != i) { |
534 core.print("Chain test failed:"); | 534 core.print("Chain test failed:"); |
535 core.print(`Expected last value to be ${i} but it was ${last.value}.`); | 535 core.print(dart.str`Expected last value to be ${i} but it was ${last.val
ue}.`); |
536 } | 536 } |
537 } | 537 } |
538 }; | 538 }; |
539 dart.fn(DeltaBlue$.chainTest, dart.void, [core.int]); | 539 dart.fn(DeltaBlue$.chainTest, dart.void, [core.int]); |
540 DeltaBlue$.projectionTest = function(n) { | 540 DeltaBlue$.projectionTest = function(n) { |
541 DeltaBlue$.planner = new DeltaBlue$.Planner(); | 541 DeltaBlue$.planner = new DeltaBlue$.Planner(); |
542 let scale = new DeltaBlue$.Variable("scale", 10); | 542 let scale = new DeltaBlue$.Variable("scale", 10); |
543 let offset = new DeltaBlue$.Variable("offset", 1000); | 543 let offset = new DeltaBlue$.Variable("offset", 1000); |
544 let src = null, dst = null; | 544 let src = null, dst = null; |
545 let dests = dart.list([], DeltaBlue$.Variable); | 545 let dests = dart.list([], DeltaBlue$.Variable); |
(...skipping 25 matching lines...) Expand all Loading... |
571 v.value = newValue; | 571 v.value = newValue; |
572 plan.execute(); | 572 plan.execute(); |
573 } | 573 } |
574 edit.destroyConstraint(); | 574 edit.destroyConstraint(); |
575 }; | 575 }; |
576 dart.fn(DeltaBlue$.change, dart.void, [DeltaBlue$.Variable, core.int]); | 576 dart.fn(DeltaBlue$.change, dart.void, [DeltaBlue$.Variable, core.int]); |
577 DeltaBlue$.planner = null; | 577 DeltaBlue$.planner = null; |
578 BenchmarkBase$.Expect = class Expect extends core.Object { | 578 BenchmarkBase$.Expect = class Expect extends core.Object { |
579 static equals(expected, actual) { | 579 static equals(expected, actual) { |
580 if (!dart.equals(expected, actual)) { | 580 if (!dart.equals(expected, actual)) { |
581 dart.throw(`Values not equal: ${expected} vs ${actual}`); | 581 dart.throw(dart.str`Values not equal: ${expected} vs ${actual}`); |
582 } | 582 } |
583 } | 583 } |
584 static listEquals(expected, actual) { | 584 static listEquals(expected, actual) { |
585 if (expected[dartx.length] != actual[dartx.length]) { | 585 if (expected[dartx.length] != actual[dartx.length]) { |
586 dart.throw(`Lists have different lengths: ${expected[dartx.length]} vs $
{actual[dartx.length]}`); | 586 dart.throw(dart.str`Lists have different lengths: ${expected[dartx.lengt
h]} vs ${actual[dartx.length]}`); |
587 } | 587 } |
588 for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) { | 588 for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) { |
589 BenchmarkBase$.Expect.equals(expected[dartx.get](i), actual[dartx.get](i
)); | 589 BenchmarkBase$.Expect.equals(expected[dartx.get](i), actual[dartx.get](i
)); |
590 } | 590 } |
591 } | 591 } |
592 fail(message) { | 592 fail(message) { |
593 dart.throw(message); | 593 dart.throw(message); |
594 } | 594 } |
595 }; | 595 }; |
596 dart.setSignature(BenchmarkBase$.Expect, { | 596 dart.setSignature(BenchmarkBase$.Expect, { |
597 methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}), | 597 methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}), |
598 statics: () => ({ | 598 statics: () => ({ |
599 equals: [dart.void, [dart.dynamic, dart.dynamic]], | 599 equals: [dart.void, [dart.dynamic, dart.dynamic]], |
600 listEquals: [dart.void, [core.List, core.List]] | 600 listEquals: [dart.void, [core.List, core.List]] |
601 }), | 601 }), |
602 names: ['equals', 'listEquals'] | 602 names: ['equals', 'listEquals'] |
603 }); | 603 }); |
604 // Exports: | 604 // Exports: |
605 exports.DeltaBlue = DeltaBlue$; | 605 exports.DeltaBlue = DeltaBlue$; |
606 exports.BenchmarkBase = BenchmarkBase$; | 606 exports.BenchmarkBase = BenchmarkBase$; |
607 }); | 607 }); |
OLD | NEW |