fast-ruby
fast-ruby copied to clipboard
Refactoring code
I noticed that many examples in code/
do not match the template.
require "benchmark/ips"
def fast
end
def slow
end
Benchmark.ips do |x|
x.report("fast code description") { fast }
x.report("slow code description") { slow }
x.compare!
end
I found following code examples where we are not following the template
https://github.com/fastruby/fast-ruby/blob/main/code/enumerable/sort-vs-sort_by.rb - Here instead of faster and fastest, can we say fast and faster
https://github.com/fastruby/fast-ruby/blob/main/code/hash/keys-include-vs-key.rb - Can we change method name to slow and faster, as we are following same template for all our examples
https://github.com/fastruby/fast-ruby/blob/main/code/hash/values-include-vs-value.rb - Can we change method name to slow and faster, as we are following same template for all our examples
https://github.com/fastruby/fast-ruby/blob/main/code/method/call-vs-send-vs-method_missing.rb - Instead of fastest, rename to fast
https://github.com/fastruby/fast-ruby/blob/main/code/proc-and-block/proc-call-vs-yield.rb - can we rename slow1, slow2 etc to what actually that method is doing
https://github.com/fastruby/fast-ruby/blob/main/code/string/mutable_vs_immutable_strings.rb - specify which is slower and faster, as per the template we follow in all examples
https://github.com/fastruby/fast-ruby/blob/main/code/string/sub!-vs-gsub!-vs-%5B%5D%3D.rb - Can we change name from slow_1
to what method is eg slow_sub