新学了几招

clock()在<time.h>里,Linux和Windows下都有。clock(3) - Linux manual page (man7.org) The clock() function returns an approximation of processor time used by the program. 这个时间是程序占用的CPU时间,不是墙上的钟(wall clock):运行期间CPU还可能执行别的程序。CLOCKS_PER_SEC一般是1000,但可能是别的值。

ftime()在<sys/timeb.h>里,Linux和Windows下都有。ftime(3) - Linux manual page (man7.org) 不过NOTE: This function is no longer provided by the GNU C library.  Use clock_gettime(2) instead. This function returns the current time as seconds and milliseconds since the Epoch [纪元; 时代; 时期], 1970-01-01 00:00:00 +0000 (UTC). Coordinated Universal Time ( UTC ) replaced Greenwich Mean Time (GMT) as the World Standard for time in 1972. 此处的f是flat的意思,因为time是一个数,不是00:00:00这样的“三维”。fopen()等的f则代表file.

rtdsc指令is used to determine how many CPU ticks took place since the processor was reset.

readlink("/proc/self/exe")能起到GetModuleFileName(NULL...)的效果。比如自己(.exe)所在路径+"/config.txt". 现在Windows可以dir "c:\users/user",即可能不用再区分path separator

shlwapi是shell light weight api的缩写。里面有不区分大小写的字符串函数(在网页里查找not case-sensitive). Linux下有strncasecmp

posted @ 2022-12-04 19:57  华容道专家  阅读(31)  评论(0)    收藏  举报