#!/usr/bin/env ruby require "bundler/setup" require "active_remote" require "benchmark/ips" class Author < ::ActiveRemote::Base attribute :guid, :string attribute :name, :string attribute :age, :integer attribute :birthday, :datetime attribute :writes_fiction, :boolean attribute :net_sales, :float end ATTRIBUTES = { :guid => "0c030733-3b78-4587-b94b-5e0cf26497c5", :name => "Charles Dickens", :age => 68, :birthday => "1812-02-07 00:00:00", :writes_fiction => true, :net_sales => 1_000_000.0 } ::Benchmark.ips do |x| x.config(:time => 20, :warmup => 10) x.report("initialize") do ::Author.new(ATTRIBUTES) end x.report("instantiate") do ::Author.instantiate(ATTRIBUTES) end x.report("init attributes") do ::Author.new(ATTRIBUTES).attributes end x.report("inst attributes") do ::Author.instantiate(ATTRIBUTES).attributes end end