Quantcast
Channel: My Pragmatic life -- a blog by Michael Grosser » Benchmark
Browsing latest articles
Browse All 3 View Live

Image may be NSFW.
Clik here to view.

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 Article


Image may be NSFW.
Clik here to view.

Check 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 Article


Image may be NSFW.
Clik here to view.

Simple 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
Browsing latest articles
Browse All 3 View Live


Latest Images