Sha256: 3371201a3b22d70344a77548f016093dd9b62ba7666381135f91b3f2a03011a1

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "stackprof"

system("#{RbConfig.ruby} bin/rake compile", err: :out, exception: true)
require "d_heap/benchmarks"
include DHeap::Benchmarks # rubocop:disable Style/MixinUsage
fill_random_vals

n = ENV.fetch("BENCH_N", 5_000_000).to_i
interval = ENV.fetch("PROF_INTERVAL", 100).to_i # measured in μs

i = 0

q = initq RbHeap
n.times { q << n }
q.clear

StackProf.run(mode: :cpu, out: "stackprof-cpu-push.dump", interval: interval) do
  while i < n
    q << random_val
    i += 1
  end
end
StackProf.run(mode: :cpu, out: "stackprof-cpu-pop.dump", interval: interval) do
  while 0 < i # rubocop:disable Style/NumericPredicate
    q.pop
    i -= 1
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
d_heap-0.6.1 benchmarks/stackprof.rb
d_heap-0.6.0 benchmarks/stackprof.rb
d_heap-0.5.0 benchmarks/stackprof.rb