{filelink=6315}
public class Chronométrage
{
/** Chronométrer une opération **/
public static void main(String[] args) throws Exception
{
long tempsDebut = System.currentTimeMillis();
for (int i = 0; i < 30; i++)
{
System.out.println(i);
Thread.sleep(100);
}
long tempsFin = System.currentTimeMillis();
float seconds = (tempsFin - tempsDebut) / 1000F;
System.out.println("Opération effectuée en: "+ Float.toString(seconds) + " secondes.");
}
}
//0.625 secondes.
/*
Affichage:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Opération effectuée en: 3.063 secondes.
*/
A Voir sur le même Sujet:
- temps ecoulé en php
- calculer temps écoulé en minutes seconde javascript
- java:le+nombre+de+jour+entre+deux+date+saisi+par+foulaire
- java tableau calculer temps
- calculer le temps ecoulé entre deux dates en java
- code en java pour calculer heure de debut d'une opération
- compter le temps en java
- temp ecouler entre 2 date javascript
- compter temps java
- afficher les secondes en java