blob: 7d00da61746684ecc423a88279bd44725253d09a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
|