Sha256: f2a96988793dcb8eefb1ebbdd17ab4c1ed040665134a2d8ea1d16cbf589de437
Contents?: true
Size: 721 Bytes
Versions: 6
Compression:
Stored size: 721 Bytes
Contents
require_relative './shared' str = 'Lorem ipsum et dolorem' rx = /\S/ trt = "\u{0080}-\u{10FFFF}" # approximation cs = CharacterSet.whitespace benchmark( caption: 'Removing non-whitespace', cases: { 'String#gsub' => -> { str.gsub(rx, '') }, 'String#tr' => -> { str.tr(trt, '') }, 'CharacterSet#keep_in' => -> { cs.keep_in(str) }, } ) str = 'Lorem ipsum ⛷ et dolorem' rx = /\p{^emoji}/ trt = "\u0000-\u{1F599}\u{1F650}-\u{10FFFF}" cs = CharacterSet.emoji benchmark( caption: 'Keeping only emoji', cases: { 'String#gsub' => -> { str.gsub(rx, '') }, 'String#tr' => -> { str.tr(trt, '') }, 'CharacterSet#keep_in' => -> { cs.keep_in(str) }, } )
Version data entries
6 entries across 6 versions & 1 rubygems