Skip to content

Instantly share code, notes, and snippets.

@takai
Created September 15, 2009 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takai/187201 to your computer and use it in GitHub Desktop.
Save takai/187201 to your computer and use it in GitHub Desktop.
user system total real
unpack: 0.000000 0.010000 0.010000 ( 0.003435)
isutf8: 0.000000 0.030000 0.030000 ( 0.032497)
regexp: 0.000000 0.000000 0.000000 ( 0.000012)
require 'benchmark'
require 'kconv'
$KCODE = 'u'
str = ARGF.read
Benchmark.bm(8) do |x|
x.report('unpack: ') do
str.unpack('U*')
end
x.report('isutf8: ') do
str.isutf8
end
x.report('regexp: ') do
/\A[\w\W]\z/ === str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment