|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 |
#include <time.h>int main(){ for
(int i = 0; i < 100000; ++i) { struct
tm tm = {}; tm.tm_year = 110; tm.tm_mon = 1; tm.tm_mday = 1; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = 1; // 修改这个对比一下 mktime(&tm); }} |
tm_isdst = 1;
time ./a.out
real 0m23.143s
user
0m22.930s
sys 0m0.188s
tm_isdst = 0;
time ./a.out
real 0m0.186s
user 0m0.001s
sys
0m0.168s
tm.tm_isdst = 87324; (随即数)
time ./a.out
real 0m24.008s
user
0m23.774s
sys 0m0.213s
由此可见,tm_isdst的值对mktime的性能有很大影响。
原文:http://www.cnblogs.com/fingers/p/3555310.html