Benchmarking. We take two competing pieces of code - could be as simpler as a one liner or as complex as an entire web framework. Then, we put them up against each other (iterations per second). At the end of the task, we come up with a single metric, a score. We use the score to compare the two competing options.
In Ruby, the Benchmark module provides methods to measure and report the time used to execute Ruby code. http://ruby-doc.org/stdlib-2.0.0/libdoc/benchmark/rdoc/Benchmark.html
Profiling. Profiling your program is a way to determining which methods are called and how long each method take to complete. This way you can detech which methods are possible bottlenecks. Profiling also tell us a lot of valuable things, like what percentage of CPU time was use where, where memory was allocated and things like that.
In Ruby, Profiling your program will slow down your execution time considerably, so activate it only when you need it. https://ruby-doc.org/stdlib-2.1.0/libdoc/profiler/rdoc/Profiler__.html
We should not use profiling to determine performance. Profiling is intented to be used in order to identify the parts of your program which take the most time.
When measuring performance, we only care about the speed of whole program taken together. Profiling in that case only skew result, instead, performance should be tested by benchmarks.
Refer:
https://ruby-doc.org/stdlib-2.1.0/libdoc/profiler/rdoc/Profiler__.html
http://ruby-doc.org/stdlib-2.0.0/libdoc/benchmark/rdoc/Benchmark.html