Created
February 15, 2011 13:40
-
-
Save qertoip/827529 to your computer and use it in GitHub Desktop.
Ruby 1.9.2-p136 String access bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding : utf-8 -*- | |
require 'benchmark' | |
#s1 = "aaaaaaaaać" * 2_00 | |
# | |
#puts Benchmark.measure() { | |
# for i in 0..2_000_000 do | |
# c = s1[i] | |
# end | |
#} | |
# | |
#exit( 0 ) | |
require 'benchmark' | |
s1 = "ąćęłńóśżź!0123456789" | |
puts Benchmark.measure { | |
1000.times { k = s1[1] } | |
} | |
s2 = "ąćęłńóśżź!0123456789" * 100_000 | |
puts Benchmark.measure { | |
1000.times { k = s2[1] } | |
} | |
exit( 0 ) | |
s = "0123456789ąćęłńóśżź!" * 1_000_000 + "KONIEC" | |
puts s.size | |
puts s.bytesize | |
puts s.encoding | |
puts "index 1" | |
puts Benchmark.measure() { | |
1000.times { k = s[1] } | |
} | |
puts "index 1_000_000" | |
puts Benchmark.measure() { | |
1000.times { k = s[1_000_000] } | |
} | |
puts "index 2_000_000" | |
puts Benchmark.measure() { | |
1000.times { k = s[20_000_000] } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment