Re: http://twitter.com/hondallica/status/436117998823165952
クソコードを見たとき: "Looking at this code is pure agony!"
同僚がバグを直してくれた時: "You are an angel sent to save me!"
| # p5-xslate (cache DISABLED) | |
| iter (10) | |
| * Elapsed: 0.058262 seconds | |
| * Secs per iter: 0.005826 secs/iter | |
| * Iter per sec: 171.638461 iter/sec | |
| iter (100) | |
| * Elapsed: 0.122816 seconds | |
| * Secs per iter: 0.001228 secs/iter | |
| * Iter per sec: 814.226159 iter/sec | |
| iter (1000) |
| # p5-xslate (cache DISABLED) | |
| iter (10) | |
| * Elapsed: 0.077450 seconds | |
| * Secs per iter: 0.007745 secs/iter | |
| * Iter per sec: 129.115558 iter/sec | |
| iter (100) | |
| * Elapsed: 0.175402 seconds | |
| * Secs per iter: 0.001754 secs/iter | |
| * Iter per sec: 570.118927 iter/sec | |
| iter (1000) |
| following shows that the Go version is MUCH faster parsing the templates, but the VM is slower. | |
| see https://github.com/lestrrat/go-xslate/tree/master/bench | |
| $ perl driver.pl | |
| # p5-xslate (cache DISABLED) | |
| iter (10) | |
| * Elapsed: 0.05115 seconds | |
| * Iter per sec: 195.503421309873 iter/sec | |
| iter (100) | |
| * Elapsed: 0.188323 seconds |
| package tokenizer | |
| /* | |
| #cgo CFLAGS: XXX CHANGE ME XXX | |
| #cfo LDFALGS: XXX CHANGE ME XXX | |
| #include <mecab.h> | |
| struct mecab_t {} | |
| */ | |
| import "C" | |
| import "errors" |
Re: http://twitter.com/hondallica/status/436117998823165952
クソコードを見たとき: "Looking at this code is pure agony!"
同僚がバグを直してくれた時: "You are an angel sent to save me!"
| use strict; | |
| use feature 'say'; | |
| use CGI; | |
| main() unless caller(); | |
| sub main { | |
| local $ENV{REQUEST_METHOD} = "GET"; | |
| qstring_is_not_empty(); | |
| qstring_is_empty(); |
| [submodule "modules/stf"] | |
| url = git://github.com/stf-storage/stf.git | |
| [submodule "modules/stf-ircbot"] | |
| url = git://github.com/stf-storage/stf-ircbot.git |
This is a VERY limited benchmark. Take with a grain of salt. (go-stf-server)[https://github.com/stf-storage/go-stf-server] is still in half baked state, but can connect to the same database as the more mature (perl version)[https://github.com/stf-storage/stf], and handle GET requests.
And since the go version is still half-baked, this benchmark is for GET only.
The original STF dispatcher PSGI application is running behind nginx reverse proxy on the same host, which handles the reproxying via X-Reproxy-URL. In this benchmark, I'm just sending GET requests directly to port 5000 (PSGI), and port 8080 (go) on the localhost via ab:
| package Text::Xslate::Loader::File; | |
| use Mouse; | |
| use Data::MessagePack; | |
| use File::Spec; | |
| use File::Temp (); | |
| use Log::Minimal; | |
| use constant ST_MTIME => 9; | |
| use Text::Xslate::Util (); |
| func murmurHash (data []byte) uint32 { | |
| const m uint32 = 0x5bd1e995 | |
| const r uint8 = 16 | |
| var length uint32 = uint32(len(data)) | |
| var h uint32 = length * m | |
| nblocks := int(length / 4) | |
| buf := bytes.NewBuffer(data) | |
| for i := 0; i < nblocks; i++ { | |
| var x uint32 |