Created
June 15, 2012 12:42
-
-
Save matt-42/2936289 to your computer and use it in GitHub Desktop.
strcmp string comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
double get_time() | |
{ | |
timespec ts; | |
clock_gettime(CLOCK_REALTIME, &ts); | |
return double(ts.tv_sec) + double(ts.tv_nsec) / 1000000000.; | |
} | |
int main() | |
{ | |
const unsigned n = 1000000; | |
double t = get_time(); | |
int k; | |
for (unsigned i = 0; i < n; i++) | |
strcmp("string", "string"); | |
std::cout << get_time() -t << std::endl; | |
t = get_time(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./a.out | |
0.00040102 (seconds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment