Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.Duration;
- import java.time.Instant;
- public class Clock {
- // Method
- public static long countTimeOfForLoops(int N){
- long start = System.currentTimeMillis();
- for(int i=0; i<Math.pow(10, N); i++){
- // Some time passes away
- }
- long end = System.currentTimeMillis();
- long elapsedTimeInMillis = end - start;
- return elapsedTimeInMillis;
- }
- public static void main(String[] args) {
- for(int i=0; i<10; i++){
- System.out.println("Time for looping " + Math.pow(10, i) + " times: " + (int)countTimeOfForLoops(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement