Templates Kendo vs Handlebars

JavaScript performance comparison

Test case created by

Preparation code

<script src="https://code.jquery.com/jquery-3.1.1.min.js"
  integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
  crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.min.js"></script>

<script src="http://kendo.cdn.telerik.com/2017.1.118/js/kendo.all.min.js> </script>


<script id="testTemplate" type="text/x-kendo-template">
    <div id="contractor_#:data.id#" class="truckActive contractorIcon">
        <div id="contractor_#:data.id#_Bubble" class="bubbleStopBorder">
            Code: #:data.contractorCode#<br />
            Name: #:data.firstName# #:data.lastName#
        </div>
    </div>
</script>

<script id="testTemplateH" type="text/x-handlebars-template">
    <div id="{{id}}">
        <div id="{{id}}_Bubble">
            Code: {{code}}<br />
            Name: {{name}}
        </div>
    </div>
</script>

<div id="attach"></div>
      
<script>
Benchmark.prototype.setup = function() {
  var object = 
  {
  id:0,
  code:"123",
  name:"elroy"
  };
  

};

Benchmark.prototype.teardown = function() {
  $("#attach).empty();

};
</script>

Preparation code output

<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.min.js"></script> <script src="http://kendo.cdn.telerik.com/2017.1.118/js/kendo.all.min.js> </script> <script id="testTemplate" type="text/x-kendo-template"> <div id="contractor_#:data.id#" class="truckActive contractorIcon"> <div id="contractor_#:data.id#_Bubble" class="bubbleStopBorder"> Code: #:data.contractorCode#<br /> Name: #:data.firstName# #:data.lastName# </div> </div> </script> <script id="testTemplateH" type="text/x-handlebars-template"> <div id="{{id}}"> <div id="{{id}}_Bubble"> Code: {{code}}<br /> Name: {{name}} </div> </div> </script> <div id="attach"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Kendo Template withBlock true
var a = 1;
pending…
Kendo Template withBlock false
var a = 1;
pending…
Handlebars Template
var template = Handlebars.compile($("#testTemplateH").html());
attach.append

$("#attach").html(template(object))
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments