Skip to content

Instantly share code, notes, and snippets.

@RobBlackwell
Last active January 4, 2016 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobBlackwell/8665740 to your computer and use it in GitHub Desktop.
Save RobBlackwell/8665740 to your computer and use it in GitHub Desktop.
Richorama's benchmark in ANSI C
#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