Skip to content

Commit

Permalink
Check replies in throughput test
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Nov 3, 2010
1 parent f25a526 commit bea6c4b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,22 @@ static void test_throughput() {

replies = malloc(sizeof(redisReply*)*1000);
t1 = usec();
for (i = 0; i < 1000; i++) assert((replies[i] = redisCommand(c,"PING")) != NULL);
for (i = 0; i < 1000; i++) {
replies[i] = redisCommand(c,"PING");
assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_STATUS);
}
t2 = usec();
for (i = 0; i < 1000; i++) freeReplyObject(replies[i]);
free(replies);
printf("\t(1000x PING: %.2fs)\n", (t2-t1)/1000000.0);

replies = malloc(sizeof(redisReply*)*1000);
t1 = usec();
for (i = 0; i < 1000; i++) assert((replies[i] = redisCommand(c,"LRANGE mylist 0 499")) != NULL);
for (i = 0; i < 1000; i++) {
replies[i] = redisCommand(c,"LRANGE mylist 0 499");
assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_ARRAY);
assert(replies[i] != NULL && replies[i]->elements == 500);
}
t2 = usec();
for (i = 0; i < 1000; i++) freeReplyObject(replies[i]);
free(replies);
Expand Down Expand Up @@ -350,7 +357,12 @@ static void cleanup() {
// redisFree(c);
// }

int main(void) {
int main(int argc, char **argv) {
if (argc > 1) {
if (strcmp(argv[1],"-s") == 0)
use_unix = 1;
}

signal(SIGPIPE, SIG_IGN);
test_format_commands();
test_blocking_connection();
Expand Down

0 comments on commit bea6c4b

Please sign in to comment.