Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Benchmarking yrmcds memcache text parser.
#include "../src/memcache/memcache.hpp"
#include <cybozu/test.hpp>
#include <cassert>
#include <cerrno>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <iostream>
#include <limits>
#include <stdlib.h>
using namespace yrmcds;
using namespace yrmcds::memcache;
#define MEMCACHE_TEST(n, d) \
char data##n[] = d; \
text_request t##n(data##n, sizeof(data##n) - 1);
AUTOTEST(speed) {
for( int i = 0; i < 1000000; i++ ) {
MEMCACHE_TEST(1, "\r\n");
MEMCACHE_TEST(2, "set aaa 100 0 5\r\nabcde\r\nset aaa");
MEMCACHE_TEST(3, "set aaa 100 0 10 \r\nabcdefghij\r\naaa");
MEMCACHE_TEST(4, "set aaa 100 0 10 noreply \r\nabcdefghij\r\naaa");
MEMCACHE_TEST(5, "add aaa 100 0 10 noreply\r\nabcdefghij\r\n");
MEMCACHE_TEST(6, "replace aaa 100 0 10 noreply \r\nabcdefghij\r\n");
MEMCACHE_TEST(7, "touch abcd 0 \r\nabc");
MEMCACHE_TEST(8, "touch abcd 100 noreply\r\nabc");
MEMCACHE_TEST(9, "get 38338 \r\nabc");
MEMCACHE_TEST(10, "get 38338 4\r\nabc");
MEMCACHE_TEST(11, "gets 38338 \r\nabc");
MEMCACHE_TEST(12, "get 38338 \r\nabc");
MEMCACHE_TEST(13, "get 38338 4\r\nabc");
MEMCACHE_TEST(14, "gets 38338 \r\nabc");
MEMCACHE_TEST(15, "get 38338 \r\nabc");
MEMCACHE_TEST(16, "get 38338 4\r\nabc");
MEMCACHE_TEST(17, "gets 38338 \r\nabc");
MEMCACHE_TEST(18, "get 38338 \r\nabc");
}
}
@ymmt2005

This comment has been minimized.

Copy link
Owner Author

ymmt2005 commented Nov 21, 2014

Result:

$ make test/memcache_text_speed
./test/memcache_text_speed.exe
ctest:module=speed
ctest:name=memcache_text_speed, module=1, total=0, ok=0, ng=0, exception=0
ctest:elapsed=941572us
@ymmt2005

This comment has been minimized.

Copy link
Owner Author

ymmt2005 commented Nov 21, 2014

18000000 / 0.941572 ≒ 1912 万 op/s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.