java - How to create a timer function? -


i have func a(x, y z) time, there way this:

time = timeit( a(x,y,z) ) in java, time accept func.

like:

long timeit(object func){     long starttime = system.currenttimemillis();     func(...);     return system.currenttimemillis() - starttime; } 

using reflection:

if functioncall() instance method
-> create object class
-> invoke method using object of class

myclass objtopass = new myclass(); method m; //assuming functioncall() takes no arguments m = myclass.class.getmethod("functioncall", new class[]{}); //parameter list empty m.invoke(objtopass, new object[]{}); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -