↧
Micro Benchmark fastest threadsave Accessor
While working on my new Fast-Gettext i needed a really fast way load the current translations, since they are needed every time, and must be stored inside Thread.current for Thread-safety. So i came up...
View ArticleCheck if a numer is a power of 2 in ruby
The One imo not-so-obvious solution is: # 0 -> false, 1->true, 2->true, 3->false ... n.to_s(2).scan(/1/).size == 1 And why it works is an exercise for the reader Update: A crazy benchmark...
View ArticleSimple Ruby Benchmark Script
Update: you might like Time.benchmark Usage benchmark "deleting users" do User.all.each(&:destroy) end Output deleting users... took 123.3435 seconds Script def benchmark(what, &block) require...
View Article