-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathperformance.rb
41 lines (35 loc) · 932 Bytes
/
performance.rb
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
#!/usr/bin/env ruby
# encoding: iso-8859-1
#--
# Portions copyright 2004 by Jim Weirich ([email protected]).
# Portions copyright 2005 by Sam Ruby ([email protected]).
# All rights reserved.
# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#++
require 'builder/xmlmarkup'
require 'benchmark'
text = "This is a test of the new xml markup. I�t�rn�ti�n�liz�ti�n\n" * 10000
include Benchmark # we need the CAPTION and FMTSTR constants
include Builder
n = 50
Benchmark.benchmark do |bm|
tf = bm.report("base") {
n.times do
x = XmlMarkup.new
x.text(text)
x.target!
end
}
def XmlMarkup._escape(text)
text.to_xs
end
tf = bm.report("to_xs") {
n.times do
x = XmlMarkup.new
x.text(text)
x.target!
end
}
end