jueves, 6 de junio de 2013

Medir Tiempo de Procesos en Java

long time_start, time_end;
time_start = System.currentTimeMillis();

metodo(); // llamamos a la tarea

time_end = System.currentTimeMillis();
long total = time_end - time_start;
int seconds = (int) (total / 1000) % 60 ;
int minutes = (int) ((total / (1000*60)) % 60);
int hours   = (int) ((total / (1000*60*60)) % 24);

System.out.println("the task has taken "+ hours + "H" + minutes + "min" +  seconds + "s" );
-->

No hay comentarios:

Publicar un comentario