Last active
January 4, 2016 19:09
-
-
Save RobBlackwell/8665740 to your computer and use it in GitHub Desktop.
Richorama's benchmark in ANSI C
This file contains 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 <stdio.h> | |
#include <uriparser/Uri.h> | |
#include <time.h> | |
int main(void) | |
{ | |
clock_t start = clock() / (CLOCKS_PER_SEC / 1000); | |
UriParserStateA state; | |
static UriUriA uris[1000000]; | |
for (int i = 0; i < 1000000; i++) { | |
state.uri = &uris[i]; | |
if (uriParseUriA(&state, "http://www.foo.com") != URI_SUCCESS) { | |
// Fail | |
} | |
} | |
clock_t end = clock() / (CLOCKS_PER_SEC / 1000); | |
printf("That took %d ms\n",(int)(end - start)); | |
return 0; | |
} | |
// ON my Intel Core i3 Linux Box | |
// cc test.c -Wall -std=c99 -luriparser | |
// ./a.out | |
// That took 440 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment