mask condition parse vs regexp

JavaScript performance comparison

Revision 2 of this test case created by tenbits

Preparation code

<script src="https://raw.github.com/tenbits/MaskJS/inline-binds/lib/mask.js">
</script>
<script>
  var conditionOld = mask.ValueUtils.condition;
</script>
<script src="https://raw.github.com/tenbits/MaskJS/master/lib/mask.js">
</script>
<script>
  var condition = mask.Utils.Condition.condition;
  var expression = mask.Utils.Expression.eval;
</script>
<script>
 
 function getTernary(){
     return (ternary += ' ');
 }
</script>
<script>
Benchmark.prototype.setup = function() {
    ternary = 'klass1=="A" && ("A"=="B" || "A"=="A") ? "isB" : "isA"'
   
};
</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
regexp parsing
conditionOld(getTernary(), {
                klass1: 'A'
});
pending…
direct/char parsing
condition(getTernary(), {
                klass1: 'A'
});
pending…
function
var f = new Function('klass1', 'return ' + getTernary());
f('A');
pending…
mask expression
expression(getTernary(), {
                klass1: 'A'
});
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