Created
August 30, 2010 23:36
-
-
Save frsyuki/558232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msgpack/rpc/client.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
int main(int argc, char* argv[]) | |
{ | |
int num = atoi(argv[1]); | |
msgpack::rpc::client c("127.0.0.1", 19701); | |
c.start(4); | |
struct timeval start_time; | |
gettimeofday(&start_time, NULL); | |
num -= 1; | |
for(int i=0; i < num; ++i) { | |
c.notify("check"); | |
} | |
c.call("check").join(); | |
struct timeval end_time; | |
gettimeofday(&end_time, NULL); | |
double time = (end_time.tv_sec - start_time.tv_sec) | |
+ (double)(end_time.tv_usec - start_time.tv_usec) / 1000 / 1000; | |
std::cout << num/time << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'msgpack/rpc' | |
num = ARGV[0].to_i | |
c = MessagePack::RPC::Client.new('127.0.0.1', 19701) | |
start = Time.now | |
(num-1).times do | |
c.notify(:check) | |
end | |
c.call(:check) # added | |
finish = Time.now | |
p num / (finish - start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ g++ -Wall -g -lmsgpack -lmsgpack-rpc -lmpio server.cc -o server | |
$ g++ -Wall -g -lmsgpack -lmsgpack-rpc -lmpio client.cc -o client | |
$ ./server & | |
$ ./client 100000 | |
166137 | |
# MacBook Pro 2.53 GHz Intel Core 2 Duo | |
# Mac OS X 10.6.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby server.rb & | |
$ ruby client.rb 100000 | |
158192.8053912108 | |
$ ruby --version | |
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] | |
# MacBook Pro 2.53 GHz Intel Core 2 Duo | |
# Mac OS X 10.6.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msgpack/rpc/server.h> | |
class myserver : public msgpack::rpc::dispatcher { | |
void dispatch(msgpack::rpc::request req) | |
{ | |
req.result_nil(); | |
} | |
}; | |
int main(void) | |
{ | |
msgpack::rpc::server svr; | |
std::auto_ptr<msgpack::rpc::dispatcher> dp(new myserver); | |
svr.serve(dp.get()); | |
svr.listen("0.0.0.0", 19701); | |
svr.run(4); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'msgpack/rpc' | |
class MyServer | |
def check | |
nil | |
end | |
end | |
svr = MessagePack::RPC::Server.new | |
svr.listen('0.0.0.0', 19701, MyServer.new) | |
svr.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment