Created
December 16, 2013 12:56
-
-
Save ncannasse/7986565 to your computer and use it in GitHub Desktop.
Perfs Check
This file contains hidden or 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
| 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