Sha256: 1e3583cfa6aebbcf11049970268fa63064a1023fb1b3e2c0cc8341c6ca27804d

Contents?: true

Size: 558 Bytes

Versions: 24

Compression:

Stored size: 558 Bytes

Contents

require_relative './shared'

str = 'Lorem ipsum et dolorem'
rx = /\S/
cs = CharacterSet.whitespace.inversion

benchmark(
  caption: 'Detecting non-whitespace',
  cases: {
    'Regexp#match?'       => -> { rx.match?(str) },
    'CharacterSet#cover?' => -> { cs.cover?(str) },
  }
)

str = 'Lorem ipsum et dolorem'
rx = /[^a-z]/i
cs = CharacterSet.new('A'..'Z') + CharacterSet.new('a'..'z')

benchmark(
  caption: 'Detecting non-letters',
  cases: {
    'Regexp#match?'       => -> { rx.match?(str) },
    'CharacterSet#cover?' => -> { cs.cover?(str) },
  }
)

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
character_set-1.8.0-java tasks/benchmarks/cover.rb
character_set-1.8.0 tasks/benchmarks/cover.rb
character_set-1.7.0-java tasks/benchmarks/cover.rb
character_set-1.7.0 tasks/benchmarks/cover.rb
character_set-1.6.0-java benchmarks/cover.rb
character_set-1.6.0 benchmarks/cover.rb
character_set-1.5.0-java benchmarks/cover.rb
character_set-1.5.0 benchmarks/cover.rb
character_set-1.4.1-java benchmarks/cover.rb
character_set-1.4.1 benchmarks/cover.rb
character_set-1.4.0-java benchmarks/cover.rb
character_set-1.4.0 benchmarks/cover.rb
character_set-1.3.0-java benchmarks/cover.rb
character_set-1.3.0 benchmarks/cover.rb
character_set-1.2.0-java benchmarks/cover.rb
character_set-1.2.0 benchmarks/cover.rb
character_set-1.1.2-java benchmarks/cover.rb
character_set-1.1.2 benchmarks/cover.rb
character_set-1.1.1-java benchmarks/cover.rb
character_set-1.1.1 benchmarks/cover.rb