Behind the scenes of hash table performance in ruby 2.4

Behind the scenes of hash table performance in ruby 2.4


Bookmark and Share

Ruby 2.4 got released this Christmas with a lot of exciting features. One of the most underrated features in ruby 2.4 is hash table improvements. Before going into details about implementation, let’s first check the benchmark to know how this change gonna affect your ruby application.

Some benchmarks are:

Getting keys and values of a hash

Output

Ruby 2.3.3

 

ruby 2.4.0

Yeah, the above two operations executed ~ 3 times faster on my laptop. Though these numbers can vary with your machine and processor, the performance improvements will be significant on all modern processors. Not all operations became 3 times faster , average perfomence improvement is more than 50%

If you are a ruby developer and excited to know what are the new features in ruby 2.4, then this feature gonna make your application faster and you don’t have to change anything in the code for that. Because these changes are backward compatible. If you are curious to know what happened behind the scenes of this performance boost, then continue reading.

Hash Table

In computing, hash table (hash map) is a data structure that is used to implement an associative array, a …

Read More

New binding.irb introduced in ruby 2.4


Bookmark and Share

Ruby 2.4 will have the feature to introduce a REPL session, using IRB, in between your code execution for better debugging. IRB, which stands for Interactive Ruby, is the standard REPL which is bundled along with ruby. Pry is a popular alternative for IRB, which has many developer-friendly features like tab compilation and syntax highlighting. One of the most heavily used features of pry is the ability to introduce a REPL session in between your code execution for better debugging. Instead of using p or puts to print the result and various variables, this helps us try out various codes and fixes in between the code to find the right solution.

binding.pry being used.

 

To use binding.irb in your code, you need to require the IRB library to your code and call binding.irb where you want to introduce the REPL.

and you will see a REPL like below.

screen-shot-2016-11-22-at-10-47-27-am

 

Read More