zed.0xff.me

Ruby: fastest way of converting string into array of characters

timecodecomment
0.147 s.bytes.to_amost fastest, but returns ASCII codes instead of chars
0.242 s.chars.to_a FASTEST
0.257 Array(s.chars)
0.265 a=[]; s.size.times{ |i| a<<s[i] }
0.268 a=[]; s.chars.each{ |c| a<<c }
0.278 s.bytes.map(&:chr)
0.513 s.scan(/./)
0.775 s.split(//)
0.795 s.split('') SLOWEST

first column is time of 100.000 iterations on Core i5 1.7GHz

code: bench-split.rb