Skip to content

Instantly share code, notes, and snippets.

@ncannasse
Created December 16, 2013 12:56
Show Gist options
  • Select an option

  • Save ncannasse/7986565 to your computer and use it in GitHub Desktop.

Select an option

Save ncannasse/7986565 to your computer and use it in GitHub Desktop.
Perfs Check
class Test {
static function fib(x) {
if( x <= 0 ) return 1;
return fib(x-1) + fib(x-2);
}
static function writeFile() {
var b = haxe.io.Bytes.alloc(65000);
for( i in 0...2 ) {
var f = sys.io.File.write("tmp.dat");
for( i in 0...3000 )
f.write(b);
f.close();
}
}
static function readFile() {
var b = haxe.io.Bytes.alloc(65000);
for( i in 0...4 ) {
var f = sys.io.File.read("tmp.dat");
for( i in 0...3000 )
f.readFullBytes(b,0,b.length);
f.close();
}
}
static function main() {
haxe.Timer.measure(function() fib(31));
haxe.Timer.measure(writeFile);
haxe.Timer.measure(readFile);
sys.FileSystem.deleteFile("tmp.dat");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment