Railsでruby1.9と1.8って実際にどれくらいパフォーマンスに差があるんだろうか。
ということで簡単なテストを試してみる。
単純にrubyの1.9と1.8でScaffoldで生成した一覧ページを測定してみる。
一覧に登録した件数は5件です。
Ruby1.8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<textarea class="ruby" cols="60" rows="5" name="code"> ab -n 100 -c 10 http://ruby18.test.com:3000/articles This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.153 (be patient).....done Server Software: Server Hostname: 192.168.1.153 Server Port: 3000 Document Path: /articles Document Length: 1322 bytes Concurrency Level: 10 Time taken for tests: 4.586803 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 188400 bytes HTML transferred: 132200 bytes Requests per second: 21.80 [#/sec] (mean) Time per request: 458.680 [ms] (mean) Time per request: 45.868 [ms] (mean, across all concurrent requests) Transfer rate: 39.90 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 201 453 69.9 459 708 Waiting: 201 432 67.5 437 662 Total: 201 453 69.9 459 708 Percentage of the requests served within a certain time (ms) 50% 459 66% 464 75% 468 80% 473 90% 479 95% 598 98% 669 99% 708 100% 708 (longest request) </textarea> |
Ruby1.9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<textarea class="ruby" cols="60" rows="5" name="code"> aab -n 100 -c 10 http://ruby19.test.com:3000/articles This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.156 (be patient).....done Server Software: WEBrick/1.3.1 Server Hostname: 192.168.1.156 Server Port: 3000 Document Path: /articles Document Length: 1322 bytes Concurrency Level: 10 Time taken for tests: 3.279068 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 196507 bytes HTML transferred: 132200 bytes Requests per second: 30.50 [#/sec] (mean) Time per request: 327.907 [ms] (mean) Time per request: 32.791 [ms] (mean, across all concurrent requests) Transfer rate: 58.25 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 1 Processing: 125 317 49.1 315 442 Waiting: 120 314 49.1 313 440 Total: 125 317 49.0 315 442 Percentage of the requests served within a certain time (ms) 50% 315 66% 316 75% 317 80% 318 90% 411 95% 411 98% 420 99% 442 100% 442 (longest request) </textarea> |
結果
1秒あたりのリクエスト数はruby1.9のほうがほぼ1.5倍の多くリクエストをこなせるということになる。
かなりシンプルなテストなのでこれを根拠にすることはできないが、もっと複雑にシステムになればなるほど
より顕著に差ができるのではないのかなと思います。
・ruby1.8
→ 20.80 request / sec
・ruby1.9
→ 30.50 request / sec