ace-tokenizer

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

<script src="//c9.io/nightwing/ace/workspace/xqtest.js"></script>


<textarea id="xq">
xquery version "3.0";
declare function local:greet($name as xs:string, $lang as xs:string?) as xs
:string {
    if ($lang = "de") then
        "Hallo " || $name
    else if ($lang = "es") then
        "Hola " || $name
    else
        "Hello " || $name
};
local:greet("Susi", "de"),
local:greet("Susi", "es"),
local:greet("Susi", "en"),
local:greet("Susi", ())

xquery version "1.0";
declare function local:fact($n as xs:integer) {
    if ($n eq 1) then
        $n
    else
        $n * local:fact($n - 1)
};
local:fact(6)
<?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore>

<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>

<book category="CHILDREN">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

<book category="WEB">
  <title lang="en">XQuery Kick Start</title>
  <author>James McGovern</author>
  <author>Per Bothner</author>
  <author>Kurt Cagle</author>
  <author>James Linn</author>
  <author>Vaidyanathan Nagarajan</author>
  <year>2003</year>
  <price>49.99</price>
</book>

<book category="WEB">
  <title lang="en">Learning XML</title>
  <author>Erik T. Ray</author>
  <year>2003</year>
  <price>39.95</price>
</book>

</bookstore>
xquery version "3.0";
let $input := doc("/db/apps/demo/data/hamlet.xml")
let $xsl := doc("/db/apps/demo/data/shakes.xsl")
return
    transform:transform($input, $xsl, ())

</textarea>
<script>
Benchmark.prototype.setup = function() {
   
    /*------------------------------------------------------*/
    lines = (document.getElementById("xq").value+"").split("\n")
    /*------------------------------------------------------*/
    Tk=require("ace-2.0/tokenizer").Tokenizer
    Jh=require("ace-2.0/mode/xquery_highlight_rules").XQueryHighlightRules
    tk2 = new Tk((new Jh).getRules());
   
    Tk=require("ace/tokenizer").Tokenizer
    Jh=require("ace/mode/xquery_highlight_rules").XQueryHighlightRules
    tk1 = new Tk((new Jh).getRules());
   
    var XQueryLexer = require("ace/mode/xquery/XQueryLexer").XQueryLexer;
   
    tk3 = new XQueryLexer();
   
    var XQueryLexer = require("ace/mode/xquery/XQueryLexer2").XQueryLexer;
   
    tk4 = new XQueryLexer();
};
</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
2.0
var state = "start"
lines.forEach(function(l) {
    state = tk2.getLineTokens(l, state).state
})
pending…
1.0
var state = "start"
lines.forEach(function(l) {
    state = tk1.getLineTokens(l, state).state
})
pending…
xqlexer
var state = "start"
lines.forEach(function(l) {
    state = tk3.getLineTokens(l, state).state
})
pending…
xqlexerModified
var state = "start"
lines.forEach(function(l) {
    state = tk4.getLineTokens(l, state).state
})
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