2014-02-16 103 views
0

我想计算在Windows任务管理器上运行的进程的运行时间。计算进程的运行时间

如果特定的过程在特定时间后运行,那么我可以结束该过程。

+4

我想要一辆新车。 – Maroun

+1

我想去月球 – Mozzie

+4

这个问题似乎是无关紧要的,因为这是一个故事,而不是一个问题。 – Maroun

回答

4

您需要使用时间函数。

//Your start time. 
long startTime = System.nanoTime(); 
//YOUR CALL GOES HERE 

//Your end time. 
long stopTime = System.nanoTime(); 

//Take the difference and that is how long it takes to execute your function. 
System.out.println(stopTime - startTime); 
+2

+1以获得正确答案,但将来尽量避免回答对问题没有最少理解的问题,也不要表现出任何努力。 – Maroun

+0

虐待尝试,但这些问题有时只是得到我最好的笑话 – Mozzie

+0

或者,如果你想回答,回答解释的概念。这种方式OP仍然需要努力获得一些有效的代码。 – christopher