Questions tagged «jump-table»

12
“切换”比“ if”快吗?
是一种switch说法实际上比更快的if声明? 我在带有/Ox标记的Visual Studio 2010的x64 C ++编译器上运行了以下代码: #include <stdlib.h> #include <stdio.h> #include <time.h> #define MAX_COUNT (1 << 29) size_t counter = 0; size_t testSwitch() { clock_t start = clock(); size_t i; for (i = 0; i < MAX_COUNT; i++) { switch (counter % 4 + 1) { case 1: counter += …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.