如何在linux上寫執行時間的程式? - Linux

By Brianna
at 2011-09-08T23:56
at 2011-09-08T23:56
Table of Contents
在windows上寫c如下
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
time_t t1,t2; // typedef time_t long;
t1 = time(NULL);
Sleep(1234);
t2 = time(NULL);
printf("%ld secs\n",t2-t1);
system("pause");
return 0;
}
可顯示執行這程式的時間約 2 sec。
請問在linux上該怎麼寫呢?
--
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
time_t t1,t2; // typedef time_t long;
t1 = time(NULL);
Sleep(1234);
t2 = time(NULL);
printf("%ld secs\n",t2-t1);
system("pause");
return 0;
}
可顯示執行這程式的時間約 2 sec。
請問在linux上該怎麼寫呢?
--
Tags:
Linux
All Comments

By John
at 2011-09-13T10:51
at 2011-09-13T10:51

By Xanthe
at 2011-09-16T05:20
at 2011-09-16T05:20

By Susan
at 2011-09-16T18:52
at 2011-09-16T18:52

By Skylar Davis
at 2011-09-21T16:50
at 2011-09-21T16:50

By Jacob
at 2011-09-25T05:14
at 2011-09-25T05:14

By Lily
at 2011-09-29T00:53
at 2011-09-29T00:53

By Harry
at 2011-10-02T06:18
at 2011-10-02T06:18

By Puput
at 2011-10-04T02:14
at 2011-10-04T02:14

By Todd Johnson
at 2011-10-06T00:21
at 2011-10-06T00:21

By Charlotte
at 2011-10-07T12:01
at 2011-10-07T12:01

By Zora
at 2011-10-10T21:43
at 2011-10-10T21:43

By Andrew
at 2011-10-13T04:42
at 2011-10-13T04:42

By Elma
at 2011-10-17T06:53
at 2011-10-17T06:53

By Ingrid
at 2011-10-17T14:16
at 2011-10-17T14:16

By Irma
at 2011-10-20T07:55
at 2011-10-20T07:55

By Ula
at 2011-10-24T18:29
at 2011-10-24T18:29

By Blanche
at 2011-10-29T12:27
at 2011-10-29T12:27
Related Posts
9/15、9/17 Linux 核心軟中斷實作-對照BSD之設計技術研討會

By Heather
at 2011-09-08T18:56
at 2011-09-08T18:56
找不到網路介面

By Andrew
at 2011-09-08T17:41
at 2011-09-08T17:41
Ubuntu寫C

By Oscar
at 2011-09-08T17:18
at 2011-09-08T17:18
RE:SSD磁柱分配方式

By Isabella
at 2011-09-08T16:02
at 2011-09-08T16:02
mount iso scripts 抓錯

By Joe
at 2011-09-08T10:23
at 2011-09-08T10:23