Created
May 30, 2013 13:12
-
-
Save profelis/5677715 to your computer and use it in GitHub Desktop.
Revisions
-
profelis created this gist
May 30, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ package ; #if macro import haxe.macro.Context; import haxe.macro.Expr; #end /** * ... * @author deep <system.grand@gmail.com> */ class Measure { /** * Usage: * Measure.run( "parse time ", b.parse(), c.parse() ); * or * Measure.run( "parse time ", { b.parse(); c.parse() } ); * * -D measure - on/off measure */ macro static public function run(msg:String, exprs:Array<Expr>) { if (Context.defined("measure")) { exprs.unshift(macro var ____t____ = haxe.Timer.stamp()); exprs.push(macro trace($v { msg } + (haxe.Timer.stamp() - ____t____))); return {expr:EBlock(exprs), pos:Context.currentPos()} } return if (exprs.length > 1) {expr:EBlock(exprs), pos:Context.currentPos()} else exprs[0]; } }