Sha256: f05e40f76670e37936062cb5ffc7a61c374eae60ca0b4094fd053e5a1f52a6b1
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# For development purposes; do not waste your tine reading it! # YAGNI # rubocop:disable all require 'test_helper' require 'benchmark' require 'benchmark/ips' # ENV['MORE'] = 'true' describe 'Internal timings' do let(:order) { Order.new } def setup reset_order Order.add_to_flags :blocked end it 'times ips' do return unless ENV['MORE'] Order.add_to_flags :blocked, reset: :hard order = Order.new Benchmark.ips do |x| x.report('assign true : ') { order.blocked = true } x.report('assign false: ') { order.blocked = false } x.report('assign "false": ') { order.blocked = 'false' } x.report('x = order.blocked? ') { x = order.blocked? } x.report('x = order.blocked ') { x = order.blocked } x.compare! end end end class BenchFoo < Minitest::Benchmark def bench_order_blocked return unless ENV['MORE'] n = 1_000_000 n = 100_000 n = 10_000 Order.add_to_flags :blocked, reset: :hard order = Order.new assert_performance_constant do |input| n.times do order.blocked = true order.blocked = !order.blocked end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
act_with_flags-0.0.7 | test/internal_benchmark_test.rb |
act_with_flags-0.0.6 | test/internal_benchmark_test.rb |
act_with_flags-0.0.4 | test/internal_benchmark_test.rb |