clock函数会导致较大误差吗?
由 user1 于 2023-01-30 07:10:23 发表,最后修改于 2023-01-30 07:11:57
#include <stdio.h>)
#include <time.h>
int x[50000000];
int main() {
for (int j=0; j<128; ++j) {
int clk = clock();
for (int i=64; i<50000000; i+=64) {
x[i] = 0x7fffffff / i;
}
printf ("%d
", clock()-clk);
}
}
运行结果
Submitting ...
Compile OK
Time (ms): 957.7285
Memory (KiB): 195324
Status: Run Finished
>>>>>>> stdout (first 512 bytes) <<<<<<<
16919
7344
7520
6817
7656
7355
Submitting ...
Compile OK
Time (ms): 928.556446
Memory (KiB): 195324
Status: Run Finished
>>>>>>> stdout (first 512 bytes) <<<<<<<
16916
7471
7665
7280
7249
7311
Submitting ...
Compile OK
Time (ms): 956.438109
Memory (KiB): 195324
Status: Run Finished
>>>>>>> stdout (first 512 bytes) <<<<<<<
16886
7254
7562
7545
7643
7516
Submitting ...
Compile OK
Time (ms): 930.359743
Memory (KiB): 195324
Status: Run Finished
>>>>>>> stdout (first 512 bytes) <<<<<<<
16922
7483
7561
7616
7329
7509
Submitting ...
Compile OK
Time (ms): 959.882703
Memory (KiB): 195324
Status: Run Finished
>>>>>>> stdout (first 512 bytes) <<<<<<<
16891
7466
7574
7008
6972
7493
Judge Duck Online | 评测鸭在线
Server Time: 2024-11-23 16:21:21 | Loaded in 6 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠