File: helpers.rb

package info (click to toggle)
ruby-benchmark-ips 1.2.0%2Bgit.20130609.e47e416-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 116 kB
  • ctags: 39
  • sloc: ruby: 308; makefile: 13
file content (46 lines) | stat: -rw-r--r-- 965 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Benchmark
  module Helpers

    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
    module_function :fixnum_max

    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 "Maximum Fixnum size now known yet for #{RUBY_ENGINE}"
        end
      else
        - 2 ** (wordsize - 2)
      end
   end
    module_function :fixnum_min

    def wordsize
      8 * 1.size
    end
    module_function :wordsize

  end
end