Module: Benchmark::Helpers

Defined in:
lib/benchmark/helpers.rb

Class Method Summary collapse

Class Method Details

.fixnum_maxObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/benchmark/helpers.rb', line 4

def fixnum_max
  if Object.const_defined?(:RUBY_ENGINE)
    case RUBY_ENGINE
    when "ruby"
      2 ** (wordsize - 2) - 1
    when "rbx"
      Fixnum::MAX
    when "jruby"
      9223372036854775807
    else
      raise "Maximum Fixnum size now known yet for #{RUBY_ENGINE}"
    end
  else
    2 ** (wordsize - 2) - 1
  end
end

.fixnum_minObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/benchmark/helpers.rb', line 22

def fixnum_min
  if Object.const_defined?(:RUBY_ENGINE)
    case RUBY_ENGINE
    when "ruby"
      - 2 ** (wordsize - 2)
    when "rbx"
      Fixnum::MIN
    when "jruby"
      -9223372036854775808
    else
      raise "Minimum Fixnum size now known yet for #{RUBY_ENGINE}"
    end
  else
    - 2 ** (wordsize - 2)
  end
end

.wordsizeObject



40
41
42
# File 'lib/benchmark/helpers.rb', line 40

def wordsize
  8 * 1.size
end