rails-api/active_model_serializers — pull request #232 by SamSaffron (2013-03-14 04:42:42+00:00)
Title: Boost AM::Serializer perf

Benchmarks (in the benchmark folder) show these changes give 3x perf for serialization under some cases.

I the real world for a big discourse page we see a 10% boost (though it was a bit bigger on 2.0 for some reason):

BEFORE:

```
sam@ubuntu:~/Source/discourse$ ab -n 30 -c 1 http://l.discourse:3000/t/install-tutorial-for-the-ruby-dumb-test/2027
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking l.discourse (be patient).....done

Server Software: thin
Server Hostname: l.discourse
Server Port: 3000

Document Path: /t/install-tutorial-for-the-ruby-dumb-test/2027
Document Length: 57264 bytes

Concurrency Level: 1
Time taken for tests: 5.182 seconds
Complete requests: 30
Failed requests: 6
(Connect: 0, Receive: 0, Length: 6, Exceptions: 0)
Write errors: 0
Total transferred: 1744598 bytes
HTML transferred: 1717909 bytes
Requests per second: 5.79 [#/sec] (mean)
Time per request: 172.719 [ms] (mean)
Time per request: 172.719 [ms] (mean, across all concurrent requests)
Transfer rate: 328.80 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 143 173 22.4 179 215
Waiting: 143 173 22.4 179 215
Total: 143 173 22.4 179 215

Percentage of the requests served within a certain time (ms)
50% 179
66% 184
75% 186
80% 188
90% 210
95% 214
98% 215
99% 215
100% 215 (longest request)

```

AFTER:

```
sam@ubuntu:~/Source/discourse$ ab -n 30 -c 1 http://l.discourse:3000/t/install-tutorial-for-the-ruby-dumb-test/2027
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking l.discourse (be patient).....done

Server Software: thin
Server Hostname: l.discourse
Server Port: 3000

Document Path: /t/install-tutorial-for-the-ruby-dumb-test/2027
Document Length: 57097 bytes

Concurrency Level: 1
Time taken for tests: 4.911 seconds
Complete requests: 30
Failed requests: 12
(Connect: 0, Receive: 0, Length: 12, Exceptions: 0)
Write errors: 0
Total transferred: 1739581 bytes
HTML transferred: 1712922 bytes
Requests per second: 6.11 [#/sec] (mean)
Time per request: 163.696 [ms] (mean)
Time per request: 163.696 [ms] (mean, across all concurrent requests)
Transfer rate: 345.93 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 140 164 25.9 145 231
Waiting: 140 164 25.9 145 231
Total: 140 164 25.9 145 231

Percentage of the requests served within a certain time (ms)
50% 145
66% 182
75% 183
80% 184
90% 199
95% 213
98% 231
99% 231
100% 231 (longest request)
```