Sha256: 7994f00972c48a17a8f21a3a700b1998b6dac707784eb86189da70434c131ea7

Contents?: true

Size: 783 Bytes

Versions: 8

Compression:

Stored size: 783 Bytes

Contents

require "dry-initializer"
require "ruby-prof"
require "fileutils"

class User
  extend Dry::Initializer

  param  :first_name,  proc(&:to_s), default: proc { "Unknown" }
  param  :second_name, proc(&:to_s), default: proc { "Unknown" }
  option :email,       proc(&:to_s), optional: true
  option :phone,       proc(&:to_s), optional: true
end

result = RubyProf.profile do
  1_000.times { User.new :Andy, email: :"andy@example.com" }
end

FileUtils.mkdir_p "./tmp"

FileUtils.touch "./tmp/profile.dot"
File.open("./tmp/profile.dot", "w+") do |output|
  RubyProf::DotPrinter.new(result).print(output, min_percent: 0)
end

FileUtils.touch "./tmp/profile.html"
File.open("./tmp/profile.html", "w+") do |output|
  RubyProf::CallStackPrinter.new(result).print(output, min_percent: 0)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dry-initializer-1.4.1 benchmarks/profiler.rb
dry-initializer-1.4.0 benchmarks/profiler.rb
dry-initializer-1.3.0 benchmarks/profiler.rb
dry-initializer-1.2.0 benchmarks/profiler.rb
dry-initializer-1.1.3 benchmarks/profiler.rb
dry-initializer-1.1.2 benchmarks/profiler.rb
dry-initializer-1.1.1 benchmarks/profiler.rb
dry-initializer-1.1.0 benchmarks/profiler.rb