YUI.Lang.sub vs strconcat

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.9.0/build/yui-base/yui-base-min.js&3.9.0/build/template-base/template-base-min.js&3.9.0/build/escape/escape-min.js&3.9.0/build/template-micro/template-micro-min.js"></script>
<script>
var Y = YUI().use('*');
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Lang.Sub
var res = Y.Lang.sub('hello, {i} {am} {a} {jsperf}', {
  i: 'i',
  am: 'am',
  a: 'a',
  jsperf: 'jsperf'
});
 
pending…
strconcat
var i = 'i';
var am = 'am';
var a = 'a';
var jsperf = 'jsperf';
var res = 'hello, ' + i + ' ' + am + ' ' + a + ' ' + jsperf;
pending…
y.template
var micro = new Y.Template()
var html  = micro.render('hello <%= this.i %> <%= this.am %> <%= this.a %> <%= this.jsperf %></i>', {i: 'i', am : 'am', a: 'a', jsperf: 'jsperf'});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment