#!/usr/bin/env ruby require 'bundler/setup' require 'benchmark/ips' require 'active_support' require 'fast_underscore' source = %w[_ - : :: / 漢字 😊🎉] + ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a words = 500.times.map { Array.new(100) { source.sample }.join } Benchmark.ips do |x| x.report('ActiveSupport') do words.each { |word| ActiveSupport::Inflector.underscore(word) } end x.report('FastUnderscore') do words.each { |word| FastUnderscore.underscore(word) } end x.compare! end