Thursday 16 February 2012

XQuery parser in Javascript performance

"even more scary is how lightning fast the exact same program is in javascript... "
@wcandillon

What are the numbers?

Gunther Rademacher's REX parser generator can target several languages including Javascript.

The Javascript output is designed for jrunscript. To see what it expects use the option:
Main program=simple
jrunscript did not work for me, nor did Rhino, probably  due to my lack of familiarity  with these tools.
I wanted to run using Node.js and this required a few changes to the javascript
  1. changing  the writeOutput function to capture the result 
  2. setting the module exports module.exports = xquery30
The node main module is:

var Xq=require("./xq3.js");
var out=[];
var parser=new Xq("2+3",out);
parser.parse_XQuery();
console.log(out.join("")); 

The numbers:

time node app.js
real 0m0.278s
user 0m0.212s
sys 0m0.020s
No doubt the c++ is faster. Perhaps the winner is EBNF.

Github: xqparserperf 

Payment service

Gumroad is a new payment service aimed at digital goods sales that works in over 190 countries. As someone who builds small web applications with subscription fees, I can honestly say that receiving payments is the least fun part of development. It’s fun getting paid, but dealing with payment provider APIs can be stressful to say the least. So I read with interest when Vadim Demedes sent us his Node Gumroad client (License: MIT, GitHub: vdemedes / node-gumroad, npm: gumroad).
dailyjs.com

 http://news.ycombinator.com/item?id=2406614

Monday 13 February 2012

XQuery parser performance

This post was updated on 15th Feb with the BaseX 7.1.1 results

A comparison of XQuery engine performance running the XQuery parser from xquerydoc project. The test parses the XQuery program string "2+3":

import module namespace p="XQueryV30" at "XQueryV30.xq";
p:parse-XQuery("2+3")

Engines

  • Zorba XQuery Engine, Version: 2.1.0
  • BaseX 7.1.1 Beta  [Standalone]
  • Saxon-HE 9.4.0.2J
  • MXQuery 0.6.0

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)


Running on Ubuntu 11.04 on a Thinkpad T42.

Zorba


time zorba -f -q test_xqparser.xq 
real 0m24.562s 
user 0m21.489s 
sys  0m0.240s

BaseX

Results for version 7.1.1 (BaseX711-20120215.234615)

time basex test_xqparser.xq
real 0m1.601s
user 0m1.260s
sys 0m0.088s
Results for version 7.1.0
time basex test_xqparser.xq
real 96m29.589s
user 54m35.961s
sys 0m19.533s

Saxon


time saxon-xq test_xqparser.xq 
real 0m2.673s
user 0m2.372s
sys  0m0.140s

MXQuery


java -Xms1024m -Xmx1024m  -jar mxquery.jar -f test_xqparser.xq
MXQuery 0.6.0
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

All scripts are run from the xqparserperf/src directory.

Github: xqparserperf 

(import-existing-source-code-to-github)