Sha256: f086c0c5e764a7f45b740d3bf0bd4be558d772f4e3c3cbfa81632ed00ba5e898

Contents?: true

Size: 770 Bytes

Versions: 7

Compression:

Stored size: 770 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true

require "benchmark/ips"
require "ruby-prof"
require "yoga/utils"

VALUES = [
  [[[[:x], :a], :b]],
  [[Set[[:a], :x], :a]],
  [[[[[[[[[[:x], :a], :c], :d], :e], :f], :d], :a], :a]]
].freeze

if ARGV[0] == "mark"
  Benchmark.ips do |bench|
    VALUES.each_with_index do |e, i|
      bench.report(i) do |times|
        i = 0
        while i < times
          Yoga::Utils.flatten_into_set(e)
          i += 1
        end
      end
    end
  end
else
  result = RubyProf.profile do
    VALUES.each do |e|
      100_000.times do
        Yoga::Utils.flatten_into_set(e)
      end
    end
  end

  printer = RubyProf::MultiPrinter.new(result)
  printer.print(path: "profile/flatten", profile: "flatten")
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
yoga-0.5.0 script/bench
yoga-0.4.2 script/bench
yoga-0.4.1 script/bench
yoga-0.3.2 script/bench
yoga-0.3.0 script/bench
yoga-0.2.1 script/bench
yoga-0.2.0 script/bench