Sha256: 067af05060fcdd8ff3be76ffb1822939322c063bd26c76eda03b4ecf62b5ac4b

Contents?: true

Size: 522 Bytes

Versions: 18

Compression:

Stored size: 522 Bytes

Contents

require_relative './shared'

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

benchmark(
  caption: 'Removing non-whitespace',
  cases: {
    'String#gsub'          => -> { str.gsub(rx, '') },
    'CharacterSet#keep_in' => -> { cs.keep_in(str) },
  }
)

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

benchmark(
  caption: 'Extracting emoji',
  cases: {
    'String#gsub'          => -> { str.gsub(rx, '') },
    'CharacterSet#keep_in' => -> { cs.keep_in(str) },
  }
)

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
character_set-1.5.0-java benchmarks/keep_in.rb
character_set-1.5.0 benchmarks/keep_in.rb
character_set-1.4.1-java benchmarks/keep_in.rb
character_set-1.4.1 benchmarks/keep_in.rb
character_set-1.4.0-java benchmarks/keep_in.rb
character_set-1.4.0 benchmarks/keep_in.rb
character_set-1.3.0-java benchmarks/keep_in.rb
character_set-1.3.0 benchmarks/keep_in.rb
character_set-1.2.0-java benchmarks/keep_in.rb
character_set-1.2.0 benchmarks/keep_in.rb
character_set-1.1.2-java benchmarks/keep_in.rb
character_set-1.1.2 benchmarks/keep_in.rb
character_set-1.1.1-java benchmarks/keep_in.rb
character_set-1.1.1 benchmarks/keep_in.rb
character_set-1.1.0-java benchmarks/keep_in.rb
character_set-1.1.0 benchmarks/keep_in.rb
character_set-1.0.0-java benchmarks/keep_in.rb
character_set-1.0.0 benchmarks/keep_in.rb