Permalink
Browse files

Add benchmark for Time#strftime

  • Loading branch information...
1 parent a78306e commit 5ca55cf4fd02e0d340ba761c6a7788451a552822 @IPGlider IPGlider committed Apr 7, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 benchmark/core/time/bench_strftime.rb
@@ -0,0 +1,21 @@
+require 'benchmark'
+require 'benchmark/ips'
+require 'time'
+
+Benchmark.ips do |x|
+ x.report "#strftime short string" do |times|
+ i = 0
+ while i < times
+ Time.now.strftime('Printed on %m/%d/%Y')
+ i += 1
+ end
+ end
+
+ x.report "#strftime large string" do |times|
+ i = 0
+ while i < times
+ Time.now.strftime('Printed on %m/%d/%Y' * 1000)
+ i += 1
+ end
+ end
+end

0 comments on commit 5ca55cf

Please sign in to comment.