Skip to content

Instantly share code, notes, and snippets.

@corroded
corroded / delete-prefix.rb
Created March 8, 2021 02:38
Quick benchmark of delete_prefix, sub, and gsub based off https://twitter.com/JemmaIssroff/status/1368204231476469760?s=20
require 'benchmark/ips'
Benchmark.ips do |bm|
MAX_LENGTH = 280
long_string = 'YOLO: the return of the comeback'
bm.report('delete_prefix') do
long_string.delete_prefix('YOLO: ')
end