Sha256: f022f00014a1139d881bb1c42d8aafd97f59c2cdac8ea30e8f23edcdb300d15f

Contents?: true

Size: 639 Bytes

Versions: 8

Compression:

Stored size: 639 Bytes

Contents

require_relative './shared'

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

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

str = 'Lörem ipsüm ⛷ et dölörem'
rx = /[\s\p{emoji}äüö]/
cs = CharacterSet.whitespace + CharacterSet.emoji + CharacterSet['ä', 'ö', 'ü']

benchmark(
  caption: 'Removing whitespace, emoji and umlauts',
  cases: {
    'String#gsub'            => -> { str.gsub(rx, '') },
    'CharacterSet#delete_in' => -> { cs.delete_in(str) },
  }
)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
character_set-1.5.0-java benchmarks/delete_in.rb
character_set-1.5.0 benchmarks/delete_in.rb
character_set-1.4.1-java benchmarks/delete_in.rb
character_set-1.4.1 benchmarks/delete_in.rb
character_set-1.4.0-java benchmarks/delete_in.rb
character_set-1.4.0 benchmarks/delete_in.rb
character_set-1.3.0-java benchmarks/delete_in.rb
character_set-1.3.0 benchmarks/delete_in.rb