forked from SumRndmDde/evil-haxe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
2 deletions.
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 |
---|---|---|
|
@@ -118,3 +118,4 @@ dev-display.hxml | |
tests/sourcemaps/bin | ||
/*_plugin.ml | ||
tests/benchs/export/ | ||
tests/benchs/dump/ |
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,3 +1,3 @@ | ||
-cp src | ||
-main Main | ||
-D test=Calls | ||
-D test=Access |
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,101 @@ | ||
package cases; | ||
|
||
import hxbenchmark.Suite; | ||
|
||
typedef Def = { | ||
var i : Int; | ||
var f : Float; | ||
@:optional var oi : Int; | ||
@:optional var of : Float; | ||
var ai : Array<Int>; | ||
var af : Array<Float>; | ||
var str : String; | ||
} | ||
typedef Obj = {>Def, | ||
var sub : Def; | ||
} | ||
|
||
class Access extends TestCase { | ||
@:analyzer(ignore) | ||
function measureReal() { | ||
var o = getObj(); | ||
var suite = new Suite("real"); | ||
suite.add(".Int", o.i); | ||
suite.add(".Float", o.f); | ||
suite.add("Int[]", o.ai[0]); | ||
suite.add("Float[]", o.af[0]); | ||
suite.add(".Int?", o.oi); | ||
suite.add(".Float?", o.of); | ||
suite.add(".String.length", o.str.length); | ||
suite.add(".sub.Int", o.sub.i); | ||
suite.add(".sub.Float", o.sub.f); | ||
suite.add(".sub.Int[]", o.sub.ai[0]); | ||
suite.add(".sub.Float[]", o.sub.af[0]); | ||
suite.add(".sub.Int?", o.sub.oi); | ||
suite.add(".sub.Float?", o.sub.of); | ||
suite.add(".sub.String.length", o.sub.str.length); | ||
return suite.run(); | ||
} | ||
|
||
@:analyzer(ignore) | ||
function measureJson() { | ||
var o:Obj = haxe.Json.parse(haxe.Json.stringify(getObj())); | ||
var suite = new Suite("json"); | ||
suite.add(".Int", o.i); | ||
suite.add(".Float", o.f); | ||
suite.add("Int[]", o.ai[0]); | ||
suite.add("Float[]", o.af[0]); | ||
suite.add(".Int?", o.oi); | ||
suite.add(".Float?", o.of); | ||
suite.add(".String.length", o.str.length); | ||
suite.add(".sub.Int", o.sub.i); | ||
suite.add(".sub.Float", o.sub.f); | ||
suite.add(".sub.Int[]", o.sub.ai[0]); | ||
suite.add(".sub.Float[]", o.sub.af[0]); | ||
suite.add(".sub.Int?", o.sub.oi); | ||
suite.add(".sub.Float?", o.sub.of); | ||
suite.add(".sub.String.length", o.sub.str.length); | ||
return suite.run(); | ||
} | ||
|
||
function measureDynamic() { | ||
var o:Dynamic = getObj(); | ||
var suite = new Suite("dynamic"); | ||
suite.add(".Int", o.i); | ||
suite.add(".Float", o.f); | ||
suite.add("Int[]", o.ai[0]); | ||
suite.add("Float[]", o.af[0]); | ||
suite.add(".Int?", o.oi); | ||
suite.add(".Float?", o.of); | ||
suite.add(".String.length", o.str.length); | ||
suite.add(".sub.Int", o.sub.i); | ||
suite.add(".sub.Float", o.sub.f); | ||
suite.add(".sub.Int[]", o.sub.ai[0]); | ||
suite.add(".sub.Float[]", o.sub.af[0]); | ||
suite.add(".sub.Int?", o.sub.oi); | ||
suite.add(".sub.Float?", o.sub.of); | ||
suite.add(".sub.String.length", o.sub.str.length); | ||
return suite.run(); | ||
} | ||
|
||
static function getObj():Obj { | ||
return { | ||
i : 1, | ||
f : 1.0, | ||
oi : 1, | ||
of : 1.0, | ||
ai : [1], | ||
af : [1.0], | ||
str : "1", | ||
sub : { | ||
i : 1, | ||
f : 1.0, | ||
oi : 1, | ||
of : 1.0, | ||
ai : [1], | ||
af : [1.0], | ||
str : "1", | ||
} | ||
}; | ||
} | ||
} |
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