diff options
author | murphy <murphy@rubychan.de> | 2005-10-29 14:10:56 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2005-10-29 14:10:56 +0000 |
commit | 18ece3991f1ed26a086bc919648bcec0f090c13d (patch) | |
tree | 77a83682f3da870be79b8fcca331c6e2eba978b9 | |
parent | b5e63b0333bed1b14ab72d0adb025b45870cafe9 (diff) | |
download | coderay-18ece3991f1ed26a086bc919648bcec0f090c13d.tar.gz |
test/ruby/test-fitter.rb --> test/ruby/test-fitter.in.rb
-rw-r--r-- | test/ruby/test-fitter.in.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/ruby/test-fitter.in.rb b/test/ruby/test-fitter.in.rb new file mode 100644 index 0000000..7d00da6 --- /dev/null +++ b/test/ruby/test-fitter.in.rb @@ -0,0 +1,45 @@ +require 'benchmark'
+require 'fits'
+
+N = 100_000
+
+def test s
+ puts s
+ Benchmark.bm 10 do |bm|
+ bm.report 'default' do
+ N.times { s =~ /\A\w+\z/ }
+ end
+
+ bm.report 'fits?' do
+ N.times { s.fits? /\w+/ }
+ end
+
+ bm.report 'f' do
+ N.times { s =~ /\w+/.f }
+ end
+
+ re = /\w+/.f
+
+ bm.report 'preparsed' do
+ N.times { s =~ re }
+ end
+ end
+ puts
+end
+
+a.fits? / bla /x
+
+test 'harmlessline'
+
+test <<EOL
+<div style=\"font-size:2px\">Destroy my HTML!
+harmlessline
+EOL
+
+test <<EOL
+harmlessline
+harmlesslineharmlessline
+<div style=\"font-size:2px\">Destroy my HTML!
+harmlessline
+EOL
+
|