程序执行时间 [英] Program execution time

查看:88
本文介绍了程序执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想花点时间执行程序,
我使用Clock()尝试过,但是它的秒数给了它,对于小程序,它为0.
因此,有人知道如何以毫秒或微秒为单位获取时间吗?

然后我想在多核系统中运行相同的程序,然后再次想测量时间.....

我正在使用ubuntu ...

谢谢.

I want to get the time taken to execute the program ,
Using Clock() I tried but its giving in second , which is 0 for small program .
So anyone knows how to get time in millisecond or micro second ?

Then I want to run the same program in multi core system and again wanna measure the time.....

I am using ubuntu...

Thanks .

推荐答案

您可以在基于Unix的系统或子系统上使用time命令:
you can use the time command on Unix based systems or subsystems:
time echo "Hello world"


时间运行echo "Hello world"
需要多长时间 它具有毫秒级的精度,并显示了在程序上花费了多少时间,等待系统以及总的执行时间


to time how long it takes to run echo "Hello world"
It has millisecond precision, and shows how much time was spent in the program, waiting on the system and the total execution time


在这里看看

http://stackoverflow.com/Questions/588307/c-obtaining-milliseconds-time-on-linux-clock-doesnt-seem-to-work-properly [
Have a look here

http://stackoverflow.com/questions/588307/c-obtaining-milliseconds-time-on-linux-clock-doesnt-seem-to-work-properly[^]


请参见 clock_gettime [
See clock_gettime[^] man page.
:)


这篇关于程序执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆