I
I
Ilya2014-04-18 11:11:24
Java
Ilya, 2014-04-18 11:11:24

How to count clocks/milliseconds in java?

Hello! The question is simple, and I think the answer will be quick. What is the equivalent of the C function clock() in Java ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Fedotov, 2014-04-18
@rpsv

In Java, you can do this:

long start = System.nanoTime();
// ... код
long stop = System.nanoTime();
System.out.println(stop-start);

A
Andrey Vershinin, 2014-04-18
@WolfdalE

Of course, there is no analogue, because. it is an interpreted language. And in the JVM, this is also unlikely to exist at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question