Skip to content

Instantly share code, notes, and snippets.

View frsyuki's full-sized avatar

Sadayuki Furuhashi frsyuki

View GitHub Profile
# zero-copy enable-disable test
require 'msgpack'
require 'benchmark'
LOOP = 100000
sizes = [10,100,1000,10000]
sizes.map! {|sz| [sz, MessagePack.pack("a"*sz)] }
Benchmark.benchmark(' ' * 30 + Benchmark::Tms::CAPTION, 30) do |b|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <libmemcached/memcached.h>
const char* g_host = "127.0.0.1";
unsigned short g_port = 11211;
#include <iostream>
#include <msgpack.hpp>
// source file
void doit_impl(void (*func)(void*, const char*, size_t), void* obj)
{
for(int i=0; i < 10; ++i) {
(*func)(obj, "test", 4);
}
}
diff --git a/src/gate/memproto/memtext.c b/src/gate/memproto/memtext.c
index 9c2b1da..89dec2c 100644
--- a/src/gate/memproto/memtext.c
+++ b/src/gate/memproto/memtext.c
@@ -85,13 +85,13 @@ static const unsigned char _memtext_key_offsets[] = {
111, 112, 113, 114, 115, 119, 120, 121,
122, 123, 127, 131, 132, 136, 138, 139,
140, 141, 142, 143, 144, 145, 146, 150,
- 151, 152, 154, 158, 162, 163, 167, 168,
- 169, 170, 171, 172, 173, 174, 175, 176,
#include <msgpack.hpp>
#include <iostream>
struct myclass {
int num;
std::string str;
MSGPACK_DEFINE(num, str);
};
int main(void)
#include <msgpack.hpp>
#include <iostream>
#include <sys/time.h>
#include <vector>
struct simple_timer {
void reset() { gettimeofday(&m_timeval, NULL); }
void show()
{
struct timeval endtime;
@frsyuki
frsyuki / gist:384544
Created April 30, 2010 00:54
MessagePack dynamic class
#include <msgpack.hpp>
#include <tr1/memory>
#include <iostream>
class dynamic {
public:
typedef std::tr1::shared_ptr<msgpack::zone> shared_zone;
dynamic() { }
@frsyuki
frsyuki / gist:470667
Created July 10, 2010 11:55
MessagePack-RPCのエラー定義案
####
## Overview
##
#
# RPCError
# |
# +-- TimeoutError
# |
# +-- ClientError
require 'rubygems'
require 'rev/websocket'
$connections = []
class MyConnection < Rev::WebSocket
def on_open
puts "WebSocket opened"
$connections << self
end
require 'rubygems'
require 'msgpack'
require 'json'
File.open(ARGV[0]) do |f|
begin
MessagePack::Unpacker.new(f).each {|obj|
puts obj.to_json
}
rescue EOFError