Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from dominichamon/master

Getting results now
  • Loading branch information...
commit 2911e98422855c64893e98be0e153a89e7fc95a0 2 parents 3a76bbf + 3b9ad5f
@joelgwebber authored
Showing with 32 additions and 33 deletions.
  1. +18 −18 dart/Bench2d.dart
  2. +14 −15 dart/Bench2d.dart.js
View
36 dart/Bench2d.dart
@@ -39,9 +39,7 @@ class Bench2d {
World world;
- bool _doDebugDraw;
-
- Bench2d([_doDebugDraw = false]) {
+ Bench2d() {
final gravity = new Vector(0, GRAVITY);
bool doSleep = true;
world = new World(gravity, doSleep, new DefaultWorldPool());
@@ -64,13 +62,13 @@ class Bench2d {
viewport = new CanvasViewportTransform(extents, extents);
viewport.scale = _VIEWPORT_SCALE;
- if (_doDebugDraw) {
- // Create our canvas drawing tool to give to the world.
- debugDraw = new CanvasDraw(viewport, ctx);
+ // Create our canvas drawing tool to give to the world.
+ debugDraw = new CanvasDraw(viewport, ctx);
- // Have the world draw itself for debugging purposes.
- world.debugDraw = debugDraw;
- }
+ // Have the world draw itself for debugging purposes.
+ world.debugDraw = debugDraw;
+
+ initialize();
}
void initialize() {
@@ -126,10 +124,8 @@ class Bench2d {
void render() {
step();
- if (_doDebugDraw) {
- ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
- world.drawDebugData();
- }
+ ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+ world.drawDebugData();
window.webkitRequestAnimationFrame((num time) {
render();
}, canvas);
@@ -146,16 +142,14 @@ class Bench2d {
}
void bench() {
- Bench2d bench2d = new Bench2d();
-
final times = new List<int>(FRAMES);
for (int i = 0; i < FRAMES; ++i) {
final watch = new Stopwatch();
watch.start();
- bench2d.step();
+ step();
watch.stop();
- times[i] = watch.elapsed() / watch.frequency();
- print(times[i]);
+ times[i] = 1000 * watch.elapsed() / watch.frequency();
+ print('$i: ${times[i]}');
}
int total = 0;
@@ -165,6 +159,12 @@ class Bench2d {
}
void main() {
+ // Render version
+ // final bench2d = new Bench2d();
+ // bench2d.initializeAnimation();
+ // bench2d.runAnimation();
+
+ // Benchmark version
final bench2d = new Bench2d();
bench2d.initialize();
bench2d.warmup();
View
29 dart/Bench2d.dart.js
@@ -239,17 +239,17 @@ Object.defineProperty(ListFactory.prototype, "setRange$3", { value: function($0,
}, enumerable: false, writable: true, configurable: true });
// ********** Code for ListIterator **************
function ListIterator(array) {
- this._array = array;
- this._pos = (0);
+ this._dart_coreimpl_array = array;
+ this._dart_coreimpl_pos = (0);
}
ListIterator.prototype.hasNext = function() {
- return this._array.get$length() > this._pos;
+ return this._dart_coreimpl_array.get$length() > this._dart_coreimpl_pos;
}
ListIterator.prototype.next = function() {
if (!this.hasNext()) {
$throw(const$0001);
}
- return this._array.$index(this._pos++);
+ return this._dart_coreimpl_array.$index(this._dart_coreimpl_pos++);
}
// ********** Code for NumImplementation **************
NumImplementation = Number;
@@ -486,12 +486,12 @@ StringBufferImpl.prototype.add = function(obj) {
var str = obj.toString();
if (str == null || str.isEmpty()) return this;
this._buffer.add(str);
- this._length = this._length + str.length;
+ this._dart_coreimpl_length = this._dart_coreimpl_length + str.length;
return this;
}
StringBufferImpl.prototype.clear = function() {
this._buffer = new Array();
- this._length = (0);
+ this._dart_coreimpl_length = (0);
return this;
}
StringBufferImpl.prototype.toString = function() {
@@ -2101,19 +2101,19 @@ function _Collections() {}
// ********** Code for _VariableSizeListIterator **************
function _VariableSizeListIterator() {}
_VariableSizeListIterator.prototype.hasNext = function() {
- return this._dom_array.get$length() > this._dom_pos;
+ return this._array.get$length() > this._pos;
}
_VariableSizeListIterator.prototype.next = function() {
if (!this.hasNext()) {
$throw(const$0001);
}
- return this._dom_array.$index(this._dom_pos++);
+ return this._array.$index(this._pos++);
}
// ********** Code for _FixedSizeListIterator **************
$inherits(_FixedSizeListIterator, _VariableSizeListIterator);
function _FixedSizeListIterator() {}
_FixedSizeListIterator.prototype.hasNext = function() {
- return this._dom_length > this._dom_pos;
+ return this._length > this._pos;
}
// ********** Code for _Lists **************
function _Lists() {}
@@ -6359,7 +6359,7 @@ Vector.prototype.toString = function() {
// ********** Code for top level **************
// ********** Library Bench2d **************
// ********** Code for Bench2d **************
-function Bench2d(_doDebugDraw) {
+function Bench2d() {
var gravity = new Vector((0), (-10));
var doSleep = true;
this.world = new World(gravity, doSleep, new DefaultWorldPool());
@@ -6410,16 +6410,15 @@ Bench2d.prototype.warmup = function() {
i < (64); ++i) this.step();
}
Bench2d.prototype.bench = function() {
- var bench2d = new Bench2d(false);
var times = new Array((256));
for (var i = (0);
i < (256); ++i) {
var watch = new StopwatchImplementation();
watch.start$0();
- bench2d.step();
+ this.step();
watch.stop();
- times.$setindex(i, watch.elapsed() / watch.frequency());
- dart_core_print(times.$index(i));
+ times.$setindex(i, (1000) * watch.elapsed() / watch.frequency());
+ dart_core_print(("" + i + ": " + times.$index(i)));
}
var total = (0);
for (var i = (0);
@@ -6429,7 +6428,7 @@ Bench2d.prototype.bench = function() {
Bench2d.prototype.initialize$0 = Bench2d.prototype.initialize;
// ********** Code for top level **************
function main() {
- var bench2d = new Bench2d(false);
+ var bench2d = new Bench2d();
bench2d.initialize$0();
bench2d.warmup();
bench2d.bench();
Please sign in to comment.
Something went wrong with that request. Please try again.