Skip to content

Instantly share code, notes, and snippets.

@a2800276
Created March 10, 2012 14:14
Show Gist options
  • Save a2800276/2011555 to your computer and use it in GitHub Desktop.
Save a2800276/2011555 to your computer and use it in GitHub Desktop.
#include "./benchmark.c"
#include "../BasicsC/string-buffer.h"
#include <string.h>
/*
* gcc -g -I . -L . -lavocado tbe_bench/str_benchmak.c
*/
void buf_bench(B * b) {
int i,j;
TRI_string_buffer_t sb;
TRI_InitStringBuffer(&sb);
for (i=0; i!=b->n; ++i) {
for (j=0; j!=1000; ++j) {
TRI_AppendCharStringBuffer(&sb, (char)(i+j)%255);
}
//printf("i,j : %d,%d\n", i,j);
}
b->bytes = 1000;
TRI_FreeStringBuffer(&sb);
}
void buf_bench2(B * b) {
int i,j;
TRI_string_buffer_t sb;
TRI_InitStringBuffer(&sb);
for (i=0; i!=b->n; ++i) {
for (j=0; j!=50; ++j) {
TRI_AppendStringStringBuffer(&sb, "Charlie Brown ist doof!");
}
}
b->bytes = strlen("Charlie Brown ist doof!") * 50;
TRI_FreeStringBuffer(&sb);
}
int main () {
B b;
memset(&b, 0, sizeof(b));
b.name = "triagens str buffer char";
b.benchmark = &buf_bench;
run(&b);
print_results(&b);
memset(&b, 0, sizeof(b));
b.name = "triagens str buffer str";
b.benchmark = &buf_bench2;
run(&b);
print_results(&b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment