Skip to content

Instantly share code, notes, and snippets.

@jcoyne
Last active May 1, 2019 01:23
Show Gist options
  • Save jcoyne/8905114 to your computer and use it in GitHub Desktop.
Save jcoyne/8905114 to your computer and use it in GitHub Desktop.
Benchmark rails/rails#13919
require 'active_support'
require 'active_support/multibyte/unicode'
string = "有名人やアニメ、風景などいろいろな画像を探したいならYahoo!検索(画像)。サイズ別、色別での絞り込みが可能なだけでなく、スライドショー機能も搭載。加えて、今検索されているキーワードもリアルタイムでわかるので、話題の画像がチェックできます。"
require 'benchmark'
n = 1_000_000
Benchmark.bmbm do |x|
x.report("for:") { for i in 1..n; ActiveSupport::Multibyte::Unicode.tidy_bytes(string); end }
end
@jcoyne
Copy link
Author

jcoyne commented Feb 9, 2014

Output:

  • UTF_16LE
ruby -Iactivesupport/lib/active_support.rb ./benchmark.rb 
Rehearsal ----------------------------------------
for:  36.390000   0.130000  36.520000 ( 36.523140)
------------------------------ total: 36.520000sec

           user     system      total        real
for:  36.370000   0.070000  36.440000 ( 36.445094)
  • UTF_8_MAC
ruby -Iactivesupport/lib/active_support.rb ./benchmark.rb 
Rehearsal ----------------------------------------
for:  36.670000   0.170000  36.840000 ( 36.852822)
------------------------------ total: 36.840000sec

           user     system      total        real
for:  36.590000   0.110000  36.700000 ( 36.714427)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment