{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:
- afficher le temp milliseconde en java
- obtenir le temps machine java
- java calculer temps ecoulé
- code java opération date systeme
- calculer un temps d'utilisation en java
- compter temps java
- le temps écoulé en java
- afficher avec un compteur dans un label en java
- calculer une durée écoulé entre deux dates en java
- java temps milliseconde