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.8.0-java tasks/benchmarks/used_by.rb
character_set-1.8.0 tasks/benchmarks/used_by.rb
character_set-1.7.0-java tasks/benchmarks/used_by.rb
character_set-1.7.0 tasks/benchmarks/used_by.rb
character_set-1.6.0-java benchmarks/used_by.rb
character_set-1.6.0 benchmarks/used_by.rb
character_set-1.5.0-java benchmarks/used_by.rb
character_set-1.5.0 benchmarks/used_by.rb
character_set-1.4.1-java benchmarks/used_by.rb
character_set-1.4.1 benchmarks/used_by.rb
character_set-1.4.0-java benchmarks/used_by.rb
character_set-1.4.0 benchmarks/used_by.rb
character_set-1.3.0-java benchmarks/used_by.rb
character_set-1.3.0 benchmarks/used_by.rb
character_set-1.2.0-java benchmarks/used_by.rb
character_set-1.2.0 benchmarks/used_by.rb
character_set-1.1.2-java benchmarks/used_by.rb
character_set-1.1.2 benchmarks/used_by.rb
character_set-1.1.1-java benchmarks/used_by.rb
character_set-1.1.1 benchmarks/used_by.rb