summaryrefslogtreecommitdiff
path: root/bench/bench_buffer_alloc.rb
blob: 551209a2d968ae788de7c7a422a81e88ea93daf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require File.expand_path(File.join(File.dirname(__FILE__), "bench_helper"))

require 'benchmark'
require 'ffi'
iter = ITER

puts "Benchmark Buffer.new(:int, 1, true)) performance, #{iter}x"
10.times {
  puts Benchmark.measure {
    iter.times { FFI::Buffer.new(:int, 1, true) }
  }
}

puts "Benchmark Buffer.new(4, 1, true)) performance, #{iter}x"
10.times {
  puts Benchmark.measure {
    iter.times { FFI::Buffer.new(4, 1, true) }
  }
}

puts "Benchmark Buffer.new(256, 1, true)) performance, #{iter}x"
10.times {
  puts Benchmark.measure {
    iter.times { FFI::Buffer.new(256, 1, true) }
  }
}