-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thomas Fuchs wrote:
Am 04.01.2007 um 13:19 schrieb Colin Mollenhour:
On 2), why can't the escapeHTML function create a div node and a text
node once one the first call and reuse it on subsequent calls? Also,
is this not a leak?
a) this is veeeery browser dependent :(
b) leak? can't see a reason why.
That's something we'd need to measure.
Let's measure. Note that I threw in two more "old school" methods
(string manipulation based).
Browser: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1)
Gecko/20061222 Firefox/2.0.0.1
Timing 10000 iterations of Prototype, Prototype-oneDiv, String.replace,
String.split...
Prototype: 2.829s @ 3535/s (n=10000)
Prototype-oneDiv: 3.795s @ 2635/s (n=10000)
String.replace: 0.640s @ 15625/s (n=10000)
String.split: 1.303s @ 7675/s (n=10000)
Rate Prototype-oneDiv Prototype String.split
String.replace
Prototype-oneDiv 2635/s -- -25% -66%
-83%
Prototype 3535/s 34% -- -54%
-77%
String.split 7675/s 191% 117% --
-51%
String.replace 15625/s 493% 342% 104%
--
Tests duration: 8.567 seconds.
Total duration: 13.127 seconds.
Browser: Opera/9.10 (X11; Linux i686; U; en)
Timing 10000 iterations of Prototype, Prototype-oneDiv, String.replace,
String.split...
Prototype: 0.554s @ 18051/s (n=10000)
Prototype-oneDiv: 0.569s @ 17575/s (n=10000)
String.replace: 1.082s @ 9242/s (n=10000)
String.split: 0.355s @ 28169/s (n=10000)
Rate String.replace Prototype-oneDiv Prototype
String.split
String.replace 9242/s -- -47% -49%
-67%
Prototype-oneDiv 17575/s 90% -- -3%
-38%
Prototype 18051/s 95% 3% --
-36%
String.split 28169/s 205% 60% 56%
--
Tests duration: 2.560 seconds.
Total duration: 6.118 seconds.
Browser: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
2.0.50727; FDM)
Timing 10000 iterations of Prototype, Prototype-oneDiv, String.replace,
String.split...
Prototype: 2.296s @ 4355/s (n=10000)
Prototype-oneDiv: 1.889s @ 5294/s (n=10000)
String.replace: 0.626s @ 15974/s (n=10000)
String.split: 1.110s @ 9009/s (n=10000)
Rate Prototype Prototype-oneDiv String.split
String.replace
Prototype 4355/s -- -18% -52%
-73%
Prototype-oneDiv 5294/s 22% -- -41%
-67%
String.split 9009/s 107% 70% --
-44%
String.replace 15974/s 267% 202% 77%
--
Tests duration: 5.921 seconds.
Total duration: 10.234 seconds.
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
Timing 10000 iterations of Prototype, Prototype-oneDiv, String.replace,
String.split...
Prototype: 2.324s @ 4303/s (n=10000)
Prototype-oneDiv: 1.761s @ 5679/s (n=10000)
String.replace: 0.492s @ 20325/s (n=10000)
String.split: 1.350s @ 7407/s (n=10000)
Rate Prototype Prototype-oneDiv String.split
String.replace
Prototype 4303/s -- -24% -42%
-79%
Prototype-oneDiv 5679/s 32% -- -23%
-72%
String.split 7407/s 72% 30% --
-64%
String.replace 20325/s 372% 258% 174%
--
Tests duration: 5.927 seconds.
Total duration: 10.194 seconds.
Browser: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5
(like Gecko)
Timing 10000 iterations of Prototype-oneDiv, Prototype, String.replace,
String.split...
Prototype-oneDiv: 2.457s @ 4070/s (n=10000)
Prototype: 2.545s @ 3929/s (n=10000)
String.replace: 2.732s @ 3660/s (n=10000)
String.split: 2.557s @ 3911/s (n=10000)
Rate String.replace String.split Prototype
Prototype-oneDiv
String.replace 3660/s -- -6% -7%
-10%
String.split 3911/s 7% -- -0%
-4%
Prototype 3929/s 7% 0% --
-3%
Prototype-oneDiv 4070/s 11% 4% 4%
--
Tests duration: 10.291 seconds.
Total duration: 32.202 seconds.
Test it yourself using your own system/browser:
http://gfx.neohub.com/benchmark/t/escapeHTML.html
cheers
- --
Marius Feraru
-----BEGIN PGP SIGNATURE-----
iD8DBQFFnlrqtZHp/AYZiNkRAsISAJwNZn6KHQA8Cz64R1xieZjL+unUaQCgsTRI
o1u0l0bFW2stZOZaEFlAfdU=
=Vkpv
-----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---