Sha256: 80343f11db4aa42a65976da220d1f043bb48dcdffc84c3ec21fb7ca0c9e07d99

Contents?: true

Size: 578 Bytes

Versions: 24

Compression:

Stored size: 578 Bytes

Contents

require_relative './shared'

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

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

str = 'Lorem ipsum et dolorem' * 20 + '⛷' + 'Lorem ipsum et dolorem' * 20
rx = /\p{emoji}/
cs = CharacterSet.emoji

benchmark(
  caption: 'Detecting emoji in a large string',
  cases: {
    'Regexp#match?'         => -> { rx.match?(str) },
    'CharacterSet#used_by?' => -> { cs.used_by?(str) },
  }
)

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
character_set-1.1.0-java benchmarks/used_by.rb
character_set-1.1.0 benchmarks/used_by.rb
character_set-1.0.0-java benchmarks/used_by.rb
character_set-1.0.0 benchmarks/used_by.rb