I compared the speed of Hash with Topaz, Ruby and Python

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]

Sequential Hash creation speed

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. Creating Hash(int)

Creating Hash(string)

Well, Topaz isn't faster than I expected. .. ..

Lookup speed

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 Lookup Hash(int)

Lookup Hash(string)

What I thought about doing

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

I compared the speed of Hash with Topaz, Ruby and Python
I replaced the numerical calculation of Python with Rust and compared the speed
I compared the speed of regular expressions in Ruby, Python, and Perl (2013 version)
I measured the speed of list comprehension, for and while with python2.7.
I compared the speed of go language web framework echo and python web framework flask
I compared the speed of the reference of the python in list and the reference of the dictionary comprehension made from the in list.
I tried to compare the processing speed with dplyr of R and pandas of Python
[Introduction to Python] I compared the naming conventions of C # and Python.
Specifying the range of ruby and python arrays
Compare the speed of Python append and map
Visualize the range of interpolation and extrapolation with python
I compared Java and Python!
I checked out the versions of Blender and Python
I compared the moving average of IIR filter type with pandas and scipy
Comparison of CoffeeScript with JavaScript, Python and Ruby grammar
Version control of Node, Ruby and Python with anyenv
I tried to automate the article update of Livedoor blog with Python and selenium.
I tried to find the entropy of the image with python
I tried "gamma correction" of the image with Python + OpenCV
I tried using the Python library from Ruby with PyCall
I wrote the basic grammar of Python with Jupyter Lab
I evaluated the strategy of stock system trading with Python.
Summary of Hash (Dictionary) operation support for Ruby and Python
I want to know the features of Python and pip
Play with the password mechanism of GitHub Webhook and Python
The story of Python and the story of NaN
Scraping with Node, Ruby and Python
I liked the tweet with python. ..
I personally compared Java and Ruby
I played with PyQt5 and Python3
Coexistence of Python2 and 3 with CircleCI (1.0)
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
I tried scraping the ranking of Qiita Advent Calendar with Python
Speed comparison of Wiktionary full text processing with F # and Python
I compared the calculation time of the moving average written in Python
[python, ruby] fetch the contents of a web page with selenium-webdriver
I want to output the beginning of the next month with Python
[Python] I thoroughly explained the theory and implementation of logistic regression
[Python] I thoroughly explained the theory and implementation of decision trees
I tried to improve the efficiency of daily work with Python
I compared python3 standard argparse and python-fire
Check the existence of the file with python
I didn't know the basics of Python
I installed and used Numba with Python3.5
The Python project template I think of.
Encrypt with Ruby (Rails) and decrypt with Python
Easy web scraping with Python and Ruby
Calculate the shortest route of a graph with Dijkstra's algorithm and Python
I set the environment variable with Docker and displayed it in Python
I tried to get the authentication code of Qiita API with Python.
I vectorized the chord of the song with word2vec and visualized it with t-SNE
I have 0 years of programming experience and challenge data processing with python
Find the general terms of the Tribonacci sequence with linear algebra and Python
I tried to verify and analyze the acceleration of Python by Cython
Get the number of articles accessed and likes with Qiita API + Python
I tried to streamline the standard role of new employees with Python
I tried to get the movie information of TMDb API with Python
Get and estimate the shape of the head using Dlib and OpenCV with python
I tried to get and analyze the statistical data of the new corona with Python: Data of Johns Hopkins University
I tried hundreds of millions of SQLite with python
[Python] I introduced Word2Vec and played with it.