Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/joelgwebber/bench2d
- Loading branch information
Showing
8 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.swp | ||
.sconsign.dblite | ||
c/flascc_build |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- | ||
Nape library from: http://napephys.com/downloads.html | ||
(nape-release.swc used for benchmarking) | ||
--> | ||
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
preinitialize="main(event)" | ||
minWidth="300" minHeight="300" | ||
frameRate="30"> | ||
|
||
<fx:Script> | ||
<![CDATA[ | ||
import mx.events.FlexEvent; | ||
import mx.controls.Alert; | ||
import flash.utils.*; | ||
import nape.space.*; | ||
import nape.geom.*; | ||
import nape.phys.*; | ||
import nape.shape.Polygon; | ||
protected const PYRAMID_SIZE:int = 40; | ||
protected const WARMUP:int = 64; | ||
protected const FRAMES:int = 256; | ||
protected var world:Space; | ||
protected const M_TO_PX:Number = 60; | ||
protected function initWorld():void { | ||
var gravity:Vec2 = new Vec2(0, -10*M_TO_PX); | ||
world = new Space(gravity); | ||
var ground:Body = new Body(BodyType.STATIC); | ||
ground.shapes.add(new Polygon(Polygon.rect(-40*M_TO_PX, 0, 80*M_TO_PX, 1))); | ||
ground.space = world; | ||
var a:Number = .5; | ||
var shape:Polygon = new Polygon(Polygon.box(a*M_TO_PX,a*M_TO_PX)); | ||
shape.material.density = 5; | ||
var x:Vec2 = new Vec2(-7*M_TO_PX, 0.75*M_TO_PX); | ||
var y:Vec2 = new Vec2(); | ||
var deltaX:Vec2 = new Vec2(0.5625*M_TO_PX, 1*M_TO_PX); | ||
var deltaY:Vec2 = new Vec2(1.125*M_TO_PX, 0.0*M_TO_PX); | ||
for (var i:int = 0; i < PYRAMID_SIZE; ++i) { | ||
y.set(x); | ||
for (var j:int = i; j < PYRAMID_SIZE; ++j) { | ||
var body:Body = new Body(); | ||
body.shapes.add(shape.copy()); | ||
body.position.set(y); | ||
body.space = world; | ||
y.addeq(deltaY); | ||
} | ||
x.addeq(deltaX); | ||
} | ||
} | ||
protected function step():void { | ||
world.step(1/60, 3, 3); | ||
} | ||
protected function warmup():void { | ||
for (var i:int = 0; i < WARMUP; ++i) { | ||
step(); | ||
} | ||
} | ||
public function mean(values : Array) : Number { | ||
var total:Number = 0; | ||
for (var i:int = 0; i < values.length; ++i) { | ||
total += values[i]; | ||
} | ||
return total / values.length; | ||
} | ||
public function stddev(values : Array, mean : Number) : Number { | ||
var variance : Number = 0; | ||
for (var i:int = 0; i < values.length; ++i) { | ||
var diff:Number = values[i] - mean; | ||
variance += diff * diff; | ||
} | ||
return Math.sqrt(variance / values.length); | ||
} | ||
protected function run():void { | ||
var times:Array = new Array(); | ||
for (var i:int = 0; i < FRAMES; i++) { | ||
var start:Number = getTimer(); | ||
step(); | ||
times[i] = getTimer() - start; | ||
} | ||
var mean:Number = mean(times); | ||
Alert.show("Benchmark complete.\nms/frame: " + mean + " +/- " + stddev(times, mean)); | ||
} | ||
protected function main(event:FlexEvent):void { | ||
initWorld(); | ||
warmup(); | ||
run(); | ||
} | ||
]]> | ||
</fx:Script> | ||
</s:Application> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/sh | ||
/opt/flex_sdk_4.6/bin/mxmlc -compiler.library-path=./Box2DFlexLib/bin/:/opt/flex_sdk_4.6/frameworks/libs/:/opt/flex_sdk_4.6/frameworks/locale/en_US/ Bench2d.mxml | ||
$FLEX_HOME/bin/mxmlc -compiler.library-path=./Box2DFlexLib/bin/:$FLEX_HOME/frameworks/libs/:$FLEX_HOME/frameworks/locale/en_US/ Bench2d.mxml | ||
$FLEX_HOME/bin/mxmlc -compiler.library-path=./NapeLib/bin/:$FLEX_HOME/frameworks/libs/:$FLEX_HOME/frameworks/locale/en_US/ Bench2dNape.mxml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# built in symbols that must always be preserved | ||
_start1 | ||
malloc | ||
free | ||
memcpy | ||
memmove | ||
flascc_uiTickProc | ||
_sync_synchronize | ||
|
||
# symbols specific to libVGL | ||
__avm2_vgl_argb_buffer | ||
vglttyioctl | ||
vgl_cur_mx | ||
vgl_cur_my |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# | ||
# You can download the FLasCC SDK here: http://gaming.adobe.com/technologies/flascc/ | ||
# you can find the latest flash runtime here: http://www.adobe.com/support/flashplayer/downloads.html | ||
# To build: | ||
# FLASCC="/path/to/flascc/sdk" ./make-flascc | ||
|
||
CFLAGS=-O4 | ||
CXXFLAGS="-O4 -fno-exceptions -fno-rtti" | ||
|
||
mkdir -p flascc_build | ||
cd flascc_build | ||
PATH="$FLASCC/usr/bin:$PATH" CC=gcc CXX=g++ CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS cmake ../Box2D_v2.2.1/ -DBOX2D_BUILD_EXAMPLES=OFF | ||
PATH="$FLASCC/usr/bin:$PATH" CC=gcc CXX=g++ CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS make -j4 | ||
|
||
# for smaller SWFs: | ||
# -flto-api=../flascc_exports.txt | ||
|
||
$FLASCC/usr/bin/g++ $CXXFLAGS -I../Box2D_v2.2.1/ ../bench2d.cpp ../bench2d_main.cpp Box2D/libBox2D.a -emit-swf -swf-version=16 -o bench_flascc.swf |