Advertisement
yacel100

Tiempo de ejecucion del proceso

Jun 12th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public class main {
  2.     public static void main(String[] args) {
  3.           // guardar timestamp inicio del programa
  4.           long start = System.currentTimeMillis();
  5.          
  6.            //aca ponemos el programa o el metodo a ejecutarse
  7.           for (int a=1; a<=1000000; a++)
  8.           {
  9.             System.out.println(a);
  10.           }
  11.          
  12.          
  13.           // calcular tiempo transcurrido
  14.           //Guardar timestamp final del programa
  15.           long end = System.currentTimeMillis();
  16.           //realiza el calculo del tiempo transcurrido
  17.           long res = end - start;
  18.          //el tiempo transcurrido calculado en segundos (1s == 1000 ms)
  19.           System.out.println("Segundos: "+res/1000);
  20.         }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement