本篇文章就執行效能來做一個比較
檔案存在
fopen | access | stat | |
time |
Tue Nov 24 13:36:27 2015
Tue Nov 24 13:36:45 2015
Total time: 18s
| Tue Nov 24 13:36:45 2015 Tue Nov 24 13:36:52 2015 Total time: 7s | Tue Nov 24 13:36:52 2015 Tue Nov 24 13:36:59 2015 Total time: 7s |
檔案不存在
fopen | access | stat | |
time | Tue Nov 24 13:38:21 2015 Tue Nov 24 13:38:34 2015 Total time: 13s | Tue Nov 24 13:38:34 2015 Tue Nov 24 13:38:41 2015 Total time: 7s | Tue Nov 24 13:38:41 2015 Tue Nov 24 13:38:48 2015 Total time: 7s |
結果:
stat跟access不相上下
stat, access都比fopen快source code download:
https://github.com/nelsonchung/nelson_sample_code_for_c/blob/master/diff_fopen_access_stat.c
沒有留言:
張貼留言