mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	The two main optimization are: - buffer writes for improved performance - avoid formatting functions when possible ``` | |compare-ruby|built-ruby| |:------------------|-----------:|---------:| |dump_all_string | 1.038| 195.925| | | -| 188.77x| |dump_all_file | 33.453| 139.645| | | -| 4.17x| |dump_all_dev_null | 44.030| 278.552| | | -| 6.33x| ```
		
			
				
	
	
		
			13 lines
		
	
	
	
		
			421 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
	
		
			421 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
prelude: |
 | 
						|
  require 'objspace'
 | 
						|
  require 'tempfile'
 | 
						|
  $objs = 1_000.times.map { Object.new }
 | 
						|
  $strings = 1_000.times.map { |i| "string #{i}" }
 | 
						|
  $file = Tempfile.new('heap')
 | 
						|
  $dev_null = File.open(File::NULL, 'w+')
 | 
						|
 | 
						|
benchmark:
 | 
						|
  dump_all_string: "ObjectSpace.dump_all(output: :string)"
 | 
						|
  dump_all_file: "ObjectSpace.dump_all(output: $file)"
 | 
						|
  dump_all_dev_null: "ObjectSpace.dump_all(output: $dev_null)"
 | 
						|
loop_count: 1
 |