From: Date: Tue, 12 Feb 2008 04:47:46 +0000 (+0530) Subject: Atomsmasher test. X-Git-Tag: 0.20~21 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=beda55e1f1e2cba7e647e2dea4c86f536052f2cb;p=awesomized%2Flibmemcached Atomsmasher test. --- diff --git a/ChangeLog b/ChangeLog index e2ef7733..b7f45663 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * Work on the UDP protocol * Added get_by_key, set_by_key tests for C++ API * Fix for limit_maxbytes to be 64bit in stats + * Added Atom Smasher test (scale baby, scale!) 0.15 Tue Jan 29 14:55:44 PST 2008 * More work on the C++ API. diff --git a/src/memslap.c b/src/memslap.c index 6027fddd..c0d20868 100644 --- a/src/memslap.c +++ b/src/memslap.c @@ -26,10 +26,10 @@ #define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers." /* Global Thread counter */ -unsigned int thread_counter; +volatile unsigned int thread_counter; pthread_mutex_t counter_mutex; pthread_cond_t count_threshhold; -unsigned int master_wakeup; +volatile unsigned int master_wakeup; pthread_mutex_t sleeper_mutex; pthread_cond_t sleep_threshhold; diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index c267fcee..abe3a21e 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -26,8 +26,11 @@ #include "test.h" +/* Number of items generated for tests */ #define GLOBAL_COUNT 100000 -#define TEST_COUNTER 100000 + +/* Number of times to run the test loop */ +#define TEST_COUNTER 500000 static uint32_t global_count; static pairs_st *global_pairs; @@ -60,45 +63,51 @@ uint8_t drizzle(memcached_st *memc) { unsigned int x; memcached_return rc; + char *return_value; + size_t return_value_length; + uint32_t flags; +infinite: + for (x= 0; x < TEST_COUNTER; x++) { - char *return_value; - size_t return_value_length; - uint32_t flags; - - for (x= 0; x < TEST_COUNTER; x++) - { - uint32_t test_bit; - uint8_t which; + uint32_t test_bit; + uint8_t which; - test_bit= random() % GLOBAL_COUNT; - which= random() % 2; + test_bit= random() % GLOBAL_COUNT; + which= random() % 2; - if (which == 0) - { - return_value= memcached_get(memc, global_keys[test_bit], global_keys_length[test_bit], - &return_value_length, &flags, &rc); - if (rc == MEMCACHED_SUCCESS && return_value) - free(return_value); - else - WATCHPOINT_ERROR(rc); - } + if (which == 0) + { + return_value= memcached_get(memc, global_keys[test_bit], global_keys_length[test_bit], + &return_value_length, &flags, &rc); + if (rc == MEMCACHED_SUCCESS && return_value) + free(return_value); + else if (rc == MEMCACHED_NOTFOUND) + continue; else { - rc= memcached_set(memc, global_pairs[test_bit].key, - global_pairs[test_bit].key_length, - global_pairs[test_bit].value, - global_pairs[test_bit].value_length, - 0, 0); - if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) - { - WATCHPOINT_ERROR(rc); - WATCHPOINT_ASSERT(0); - } + WATCHPOINT_ERROR(rc); + WATCHPOINT_ASSERT(rc); + } + } + else + { + rc= memcached_set(memc, global_pairs[test_bit].key, + global_pairs[test_bit].key_length, + global_pairs[test_bit].value, + global_pairs[test_bit].value_length, + 0, 0); + if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) + { + WATCHPOINT_ERROR(rc); + WATCHPOINT_ASSERT(0); } } } + if (getenv("MEMCACHED_ATOM_BURIN_IN")) + goto infinite; + return 0; } @@ -142,19 +151,20 @@ memcached_return enable_consistent(memcached_st *memc) return MEMCACHED_SUCCESS; } -test_st generate_tests[] ={ +test_st smash_tests[] ={ {"generate_pairs", 1, generate_pairs }, + {"drizzle", 1, drizzle }, {"cleanup", 1, cleanup_pairs }, {0, 0, 0} }; collection_st collection[] ={ - {"generate", 0, 0, generate_tests}, - {"generate_hsieh", pre_hsieh, 0, generate_tests}, - {"generate_hsieh_consistent", enable_consistent, 0, generate_tests}, - {"generate_md5", pre_md5, 0, generate_tests}, - {"generate_nonblock", pre_nonblock, 0, generate_tests}, + {"smash", 0, 0, smash_tests}, + {"smash_hsieh", pre_hsieh, 0, smash_tests}, + {"smash_hsieh_consistent", enable_consistent, 0, smash_tests}, + {"smash_md5", pre_md5, 0, smash_tests}, + {"smash_nonblock", pre_nonblock, 0, smash_tests}, {0, 0, 0, 0} };