I compared the speed of Hash using Topaz, a rumored Ruby implementation that uses RPython to make it faster.
It has been pointed out that Ruby's Hash is slower than other languages. It's said that larger sizes are slower than Perl and Python. (I forgot where the comparison with Perl was)
So, I made a comparison with a faint expectation that it would be faster if Topaz was used.
For the introduction of Topaz, I referred to Playing with Topaz, a Ruby processing system written in RPython-Gunara-kun's wktk management diary.
The code used for comparison can be found on Github. This time, I've cut corners and haven't averaged. As a reference value.
The environment is MacOS X 10.8.2 Intel Core i5 2.5GHz 8GB RAM
python
$ ruby -v
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12.2.1]
$ python --version
Python 2.7.3
$ bin/topaz -v
topaz (ruby-1.9.3p125) [x86_64-darwin]
The unit is seconds
size | Ruby1.9.3(int) | Ruby1.9.3(string) | topaz(int) | topaz(string) | Python2.7.3(int) | Python2.7.3(string) |
---|---|---|---|---|---|---|
5000000 | 4.617856 | 8.087801 | 2.649405 | 11.485846 | 0.702034 | 2.473861 |
10000000 | 10.74621 | 19.092902 | 8.377534 | 36.823358 | 1.361577 | 5.112283 |
15000000 | 17.081968 | 29.101156 | 18.608418 | 80.467088 | 2.262289 | 8.392108 |
20000000 | 24.308324 | 39.974923 | 29.239815 | 129.432628 | 2.712998 | 10.639115 |
25000000 | 31.778632 | 51.38185 | 49.467747 | 303.785251 | 4.048304 | 15.097062 |
30000000 | 39.180657 | 60.673959 | 67.91127 | 342.049215 | 4.510771 | 17.036763 |
The graph looks like this.
Well, Topaz isn't faster than I expected. .. ..
The unit is seconds
size | Ruby1.9.3(int) | Ruby1.9.3(string) | topaz(int) | topaz(string) | Python2.7.3(int) | Python2.7.3(string) |
---|---|---|---|---|---|---|
5000000 | 0.600543 | 0.908508 | 0.442561 | 0.678826 | 0.164233 | 0.456206 |
10000000 | 0.631404 | 1.027941 | 0.49407 | 0.738537 | 0.165629 | 0.457019 |
15000000 | 0.665743 | 0.913473 | 0.585652 | 0.883217 | 0.157661 | 0.462758 |
20000000 | 0.72521 | 1.288778 | 0.599958 | 0.93315 | 0.19554 | 0.452863 |
25000000 | 0.561795 | 0.877556 | 0.780173 | 1.232231 | 0.163047 | 0.478319 |
30000000 | 0.657025 | 1.296413 | 0.783736 | 1.353858 | 0.160251 | 0.456952 |
Click here for the graph
I'm looking forward to Topaz as it could be faster in the future, but at the moment
There are also various strict points such as. I look forward to future development.
Recommended Posts