From: Brian Aker Date: Sat, 13 Oct 2007 17:13:30 +0000 (-0700) Subject: Refactor test system to give me times on calling tests (frankly I still need X-Git-Tag: 0.7~40 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9e9572af3e9be02dd3de5c71bf1665217a770e1b;p=awesomized%2Flibmemcached Refactor test system to give me times on calling tests (frankly I still need to refactor the test system a bit more...) --- diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 6bbb387f..5a8701fa 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -35,8 +35,6 @@ static memcached_return memcached_send(memcached_st *ptr, assert(value); assert(value_length); - memset(buffer, 0, MEMCACHED_DEFAULT_COMMAND_SIZE); - /* Leaving this assert in since only a library fubar could blow this */ if (ptr->write_buffer_offset != 0) { diff --git a/tests/test.c b/tests/test.c index 0e2bc100..755455f6 100644 --- a/tests/test.c +++ b/tests/test.c @@ -6,6 +6,18 @@ #include #include #include +#include + +long int timedif(struct timeval a, struct timeval b) +{ + register int us, s; + + us = a.tv_usec - b.tv_usec; + us /= 1000; + s = a.tv_sec - b.tv_sec; + s *= 1000; + return s + us; +} void init_test(memcached_st *not_used) { @@ -645,6 +657,8 @@ int main(int argc, char *argv[]) memcached_st *memc; memcached_return rc; + struct timeval start_time, end_time; + memc= memcached_create(NULL); assert(memc); @@ -660,8 +674,12 @@ int main(int argc, char *argv[]) } fprintf(stderr, "Testing %s", tests[x].function_name); + gettimeofday(&start_time, NULL); tests[x].function(memc); - fprintf(stderr, "\t\t\t\t\t[ ok ]\n"); + gettimeofday(&end_time, NULL); + long int load_time= timedif(end_time, start_time); + fprintf(stderr, "\t\t\t\t\t %ld.%03ld [ ok ]\n", load_time / 1000, + load_time % 1000); assert(memc); memcached_free(memc); } @@ -678,6 +696,8 @@ int main(int argc, char *argv[]) memcached_st *memc; memcached_return rc; + struct timeval start_time, end_time; + memc= memcached_create(NULL); assert(memc); @@ -686,8 +706,12 @@ int main(int argc, char *argv[]) fprintf(stderr, "Testing %s", tests[x].function_name); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, NULL); + gettimeofday(&start_time, NULL); tests[x].function(memc); - fprintf(stderr, "\t\t\t\t\t[ ok ]\n"); + gettimeofday(&end_time, NULL); + long int load_time= timedif(end_time, start_time); + fprintf(stderr, "\t\t\t\t\t %ld.%03ld [ ok ]\n", load_time / 1000, + load_time % 1000); assert(memc); memcached_free(memc); } @@ -704,6 +728,8 @@ int main(int argc, char *argv[]) memcached_st *memc; memcached_return rc; + struct timeval start_time, end_time; + memc= memcached_create(NULL); assert(memc); @@ -713,8 +739,12 @@ int main(int argc, char *argv[]) fprintf(stderr, "Testing %s", tests[x].function_name); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, NULL); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, NULL); + gettimeofday(&start_time, NULL); tests[x].function(memc); - fprintf(stderr, "\t\t\t\t\t[ ok ]\n"); + gettimeofday(&end_time, NULL); + long int load_time= timedif(end_time, start_time); + fprintf(stderr, "\t\t\t\t\t %ld.%03ld [ ok ]\n", load_time / 1000, + load_time % 1000); assert(memc); memcached_free(memc); } @@ -731,6 +761,8 @@ int main(int argc, char *argv[]) memcached_st *memc; memcached_return rc; + struct timeval start_time, end_time; + memc= memcached_create(NULL); assert(memc); @@ -739,8 +771,12 @@ int main(int argc, char *argv[]) fprintf(stderr, "Testing %s", tests[x].function_name); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_MD5_HASHING, NULL); + gettimeofday(&start_time, NULL); tests[x].function(memc); - fprintf(stderr, "\t\t\t\t\t[ ok ]\n"); + gettimeofday(&end_time, NULL); + long int load_time= timedif(end_time, start_time); + fprintf(stderr, "\t\t\t\t\t %ld.%03ld [ ok ]\n", load_time / 1000, + load_time % 1000); assert(memc); memcached_free(memc); } @@ -757,6 +793,8 @@ int main(int argc, char *argv[]) memcached_st *memc; memcached_return rc; + struct timeval start_time, end_time; + memc= memcached_create(NULL); assert(memc); @@ -764,8 +802,12 @@ int main(int argc, char *argv[]) assert(rc == MEMCACHED_SUCCESS); fprintf(stderr, "Testing %s", user_tests[x].function_name); + gettimeofday(&start_time, NULL); user_tests[x].function(memc); - fprintf(stderr, "\t\t\t\t\t[ ok ]\n"); + gettimeofday(&end_time, NULL); + long int load_time= timedif(end_time, start_time); + fprintf(stderr, "\t\t\t\t\t %ld.%03ld [ ok ]\n", load_time / 1000, + load_time % 1000); assert(memc); memcached_free(memc); }