File: typecast_ips.rb

package info (click to toggle)
ruby-flipper 0.26.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,288 kB
  • sloc: ruby: 16,377; sh: 61; javascript: 24; makefile: 14
file content (19 lines) | stat: -rw-r--r-- 944 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'bundler/setup'
require 'flipper'
require 'benchmark/ips'

Benchmark.ips do |x|
  x.report("Typecast.to_boolean true") { Flipper::Typecast.to_boolean(true) }
  x.report("Typecast.to_boolean 1") { Flipper::Typecast.to_boolean(1) }
  x.report("Typecast.to_boolean 'true'") { Flipper::Typecast.to_boolean('true'.freeze) }
  x.report("Typecast.to_boolean '1'") { Flipper::Typecast.to_boolean('1'.freeze) }
  x.report("Typecast.to_boolean false") { Flipper::Typecast.to_boolean(false) }

  x.report("Typecast.to_integer 1") { Flipper::Typecast.to_integer(1) }
  x.report("Typecast.to_integer '1'") { Flipper::Typecast.to_integer('1') }

  x.report("Typecast.to_float 1") { Flipper::Typecast.to_float(1) }
  x.report("Typecast.to_float '1'") { Flipper::Typecast.to_float('1'.freeze) }
  x.report("Typecast.to_float 1.01") { Flipper::Typecast.to_float(1) }
  x.report("Typecast.to_float '1.01'") { Flipper::Typecast.to_float('1'.freeze) }
end