Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class main {
- public static void main(String[] args) {
- // guardar timestamp inicio del programa
- long start = System.currentTimeMillis();
- //aca ponemos el programa o el metodo a ejecutarse
- for (int a=1; a<=1000000; a++)
- {
- System.out.println(a);
- }
- // calcular tiempo transcurrido
- //Guardar timestamp final del programa
- long end = System.currentTimeMillis();
- //realiza el calculo del tiempo transcurrido
- long res = end - start;
- //el tiempo transcurrido calculado en segundos (1s == 1000 ms)
- System.out.println("Segundos: "+res/1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement