intermediate/ProfilingNoop

From ggc

Jump to: navigation, search

01 package intermediate;
02 
03 
04 /**
05  * All about my application.
06  @author Jam Jenkins
07  */
08 public class ProfilingNoop
09 {
10   public static void main(String[] args)
11   {
12     int noops=0;
13     long start=System.currentTimeMillis();
14     int size=1600;
15     int dummy=0;
16     while(System.currentTimeMillis()<start+1000)
17     {
18       for(int j=0; j<size; j++)
19         for(int i=0; i<size; i++)
20           //for(int i=size; i>0; i/=2)
21           dummy++;//noop
22       noops++;
23     }
24     System.out.println("I can do "+noops+" in 1 second.");
25     double timePerNoop=1.0/noops;
26     System.out.println("Each noop takes "+timePerNoop+" seconds.");
27   }
28 }


Download/View intermediate/ProfilingNoop.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter