[ruby/irb] Detect multiple lines output simplify
The old implementation performance test code:
require 'objspace' puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) /\A.*\Z/ !~ ('abc' * 20_000_000) puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001)
and run time test.rb:
time test.rb
2.5868 MB 62.226 MB real 0m1.307s user 0m0.452s sys 0m0.797s
The new implementation performance test code:
require 'objspace' puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) ('abc' * 20_000_000).include?("\n") puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001)
2.5861 MB 62.226 MB real 0m0.132s user 0m0.088s sys 0m0.042s
https://github.com/ruby/irb/commit/40d6610baf
[ruby/irb] Detect multiple lines output simplify
The old implementation performance test code:
and run
time test.rb
:The new implementation performance test code:
and run
time test.rb
:https://github.com/ruby/irb/commit/40d6610baf