J
Joshua Ball
[Note: parts of this message were removed to make it a legal post.]
A friend recently sent me this article:
http://blog.metasploit.com/2009/03/blog-post.html
In particular, note the perf difference of += vs << :
framework3 $ time ruby -e 'a = "A"; 100000.times { a << "A" }'
Also note:
*Before you run off and change every instance of += to << in your ruby code*,
Thought I would pass it along...
A friend recently sent me this article:
http://blog.metasploit.com/2009/03/blog-post.html
In particular, note the perf difference of += vs << :
framework3 $ time ruby -e 'a = "A"; 100000.times { a << "A" }'
real 0m*0.338s*
user 0m*0.312s*
sys 0m0.024s
framework3 $ time ruby -e 'a = "A"; 100000.times { a += "A" }'
real 0m*15.462s*
user 0m*15.321s*
sys 0m0.068s
Also note:
*Before you run off and change every instance of += to << in your ruby code*,
it's important to note that the two don't perform the same operation.
Because ruby does assignment by reference, the latter overwrites any
variables that point to the one you're operating on while the former leaves
any references untouched.
framework3 $ irb
=> "C"
Thought I would pass it along...