Sha256: c013596707f02c77818befb272627b986fb6fc718f0d11a28948822fc2943ade

Contents?: true

Size: 629 Bytes

Versions: 10

Compression:

Stored size: 629 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 + CS['ä', 'ü', 'ö']

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
character_set-1.2.0-java benchmarks/delete_in.rb
character_set-1.2.0 benchmarks/delete_in.rb
character_set-1.1.2-java benchmarks/delete_in.rb
character_set-1.1.2 benchmarks/delete_in.rb
character_set-1.1.1-java benchmarks/delete_in.rb
character_set-1.1.1 benchmarks/delete_in.rb
character_set-1.1.0-java benchmarks/delete_in.rb
character_set-1.1.0 benchmarks/delete_in.rb
character_set-1.0.0-java benchmarks/delete_in.rb
character_set-1.0.0 benchmarks/delete_in.rb