x86的MOV真的可以“免费”吗?为什么我不能复制这个?
#include <limits.h>#include <stdio.h>#include <time.h>int main(void){ unsigned int k, l, j; clock_t tstart = clock(); for (k = 0, j = 0, l = 0; j < UINT_MAX; ++j) { ++k; k = j; // <-- comment out this line to remove the MOV instruction l += j; } fprintf(stderr, "%d ms\n", (int)((clock() - tstart) * 1000 / CLOCKS_PER_SEC)); fflush(stderr); return (int)(k + j + l);}
LOOP: add edi,esi mov ebx,esi inc esi cmp esi,FFFFFFFFh jc LOOP
Without MOV With MOV 1303 ms 1358 ms 1324 ms 1363 ms 1310 ms 1345 ms 1304 ms 1343 ms 1309 ms 1334 ms 1312 ms 1336 ms 1320 ms 1311 ms 1302 ms 1350 ms 1319 ms 1339 ms 1324 ms 1338 ms
吃鸡游戏
相关分类