Created
April 9, 2014 01:04
-
-
Save anonymous/10215585 to your computer and use it in GitHub Desktop.
MojoX::JSON::XS(monkey patch) vs json handler(JSON::XS)
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
# MojoX::JSON::XS | |
``` | |
sub startup { | |
.... | |
$self->plugin('MojoX::JSON::XS'); | |
} | |
``` | |
``` | |
Concurrency Level: 10 | |
Time taken for tests: 41.232 seconds | |
Complete requests: 1000 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 36181000 bytes | |
HTML transferred: 36029000 bytes | |
Requests per second: 24.25 [#/sec] (mean) | |
Time per request: 412.317 [ms] (mean) | |
Time per request: 41.232 [ms] (mean, across all concurrent requests) | |
Transfer rate: 856.94 [Kbytes/sec] received | |
``` | |
# JSON::XS Handler | |
``` | |
sub startup { | |
... | |
$self->renderer->add_handler( json => sub { | |
my (undef, $c, $output, $options) = @_; | |
$$output = $c->get('JSON')->encode($options->{json} || {}); | |
}); | |
} | |
``` | |
``` | |
Concurrency Level: 10 | |
Time taken for tests: 41.249 seconds | |
Complete requests: 1000 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 36181000 bytes | |
HTML transferred: 36029000 bytes | |
Requests per second: 24.24 [#/sec] (mean) | |
Time per request: 412.490 [ms] (mean) | |
Time per request: 41.249 [ms] (mean, across all concurrent requests) | |
Transfer rate: 856.58 [Kbytes/sec] received | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment