Skip to content

Instantly share code, notes, and snippets.

@enebo
Created January 24, 2013 16:09
Show Gist options
  • Save enebo/4624040 to your computer and use it in GitHub Desktop.
Save enebo/4624040 to your computer and use it in GitHub Desktop.
BEFORE:
/c/opt/jruby master 484% jruby write2.rb
1410
Took 0.072
2820
Took 0.144
5640
Took 0.043
11280
Took 0.17
22560
Took 0.671
45120
Took 2.711
90240
Took 10.831
180480
#...abort
AFTER:
/c/opt/jruby master * 466% ./bin/jruby write2.rb
1410
HERE
Took 0.003
2820
HERE
Took 0.002
5640
HERE
Took 0.002
11280
HERE
Took 0.003
22560
HERE
Took 0.005
45120
HERE
Took 0.009
90240
HERE
Took 0.017
180480
HERE
Took 0.035
360960
HERE
Took 0.067
721920
HERE
Took 0.064
# coding: UTF-8
s = <<EOD
As an expert on Greenland who has traveled 23\n times to the massive, mile thick northern ice sheet, Box has shown an uncanny ability to predict major melts and breakoffs of Manhattan-sized ice chunks. A few years back, he foretold the release of a "4x Manhattans" piece of ice from Greenland's \nPetermann Glacier, one so big that once afloat it was dubbed an "ice island." In a scientific paper published in February of 2012, Box further predicted "100 % melt\n area over the ice sheet" within another decade of global warming. As it happened, the ice sheet's surface almost completely melted just a month later in July; an event that, in Box's words, "signals the beginning of the end for the ice sheet."
EOD
1.upto(10) do |i|
t = s
i.times { t += t }
puts t.length
time = Time.now
File.open("foo1", "w") { |f| f.write t }
puts "Took #{Time.now - time}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment