Linux C獲取系統的執行時間

2021-07-09 16:06:55 字數 643 閱讀 6974

sysinfo結構保持了系統啟動後的資訊,主要包括啟動到現在的時間,可用記憶體空間、共享記憶體空間、程序的數目等。man sysinfo得到結果如下所示:

struct sysinfo ;
通過sysinfo獲取系統啟動到現在的秒數,

#include 

#include

#include

#include

#include

#include

int main(void)

long timenum=info.uptime;

int runday=timenum/86400;

int runhour=(timenum%86400)/3600;

int runmin=(timenum%3600)/60;

int runsec=timenum%60;

bzero(run_time, 128);

sprintf(run_time,"系統已執行:%d天%d時%d分%d秒",runday,runhour,runmin,runsec);

printf("--->%s\n",run_time);

return

0; }

VC 獲取程式執行時間和系統執行時間

cstring str,str1 獲取程式執行時間 long t1 gettickcount 程式段開始前取得系統執行時間 ms sleep 500 afxmessagebox do something.long t2 gettickcount 程式段結束後取得系統執行時間 ms str.forma...

VC獲取系統時間 程式執行時間

1.使用ctime類 cstring str 獲取系統時間 ctime tm tm ctime getcurrenttime str tm.format 現在時間是 y年 m月 d日 x messagebox str,null,mb ok 2 得到系統時間日期 使用getlocaltime syst...

VC獲取系統時間 程式執行時間

1.使用ctime類 cstring str 獲取系統時間 ctime tm tm ctime getcurrenttime str tm.format 現在時間是 y年 m月 d日 x messagebox str,null,mb ok 2 得到系統時間日期 使用getlocaltime syst...