Hi Pirmin,
Interesting - and thanks for your work.
As a user I can live with different syntax as long as it is familiar.
Either Python, SQL or javascipt syntax would be fine for me. All three
are fairly common and documented.
If it speeds up things substantially, I would happily switch to
javascript syntax.
Andreas
On Tue, 10 Jan 2012 01:00:11 +0100, Pirmin Kalberer wrote:
Hi all,
Following the recent enhancements of QGsExpression, I was wondering
whether it
wouldn't make sense to integrate a language intepreter instead of
creating
another language.
One candidate would be Google's V8 JavaScript engine
(http://code.google.com/p/v8/). Since embedding this C++ library is
easy, I've
conducted a few quick benchmarks against QgsExpression. Code is
attached.
Test 1:
Qgs: '1' || '2' || '3' || '4' || '5' || '6' || '7' || '8' || '9' ||
'0'
total_avg: 3.380211
V8: '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '0'
total_avg: 0.556035
Fact: 6.0791335
Test 2:
Qgs: 1+1=2 AND 5>1
total_avg: 4.072254
V8: 1+1==2 && 5>4
total_avg: 0.864054
Fact: 4.7129624
Test 3:
Qgs: replace(lower( 'AAAAAAAAAAxxCCCCCCCC'), 'xx', 'BB')
total_avg: 3.480217
V8: 'AAAAAAAAAAxxCCCCCCCC'.toLowerCase().replace('xx', 'BB')
total_avg: 0.856053
Fact: 4.0654224
Test 4:
Qgs: regexp_replace( 'AAAAAAAAAAxxCCCCCCCC', 'x+', 'b')
total_avg: 2.952184
V8: 'AAAAAAAAAAxxCCCCCCCC'.replace(/x+/, 'b')
total_avg: 0.668042
Fact: 4.4191593
Test 5:
Qgs: CASE WHEN (15 = 11 or 15 = 13 or 15 = 15 or 15 = 21) THEN 15 END
total_avg: 1.4664916
V8: if ([11,13,15,21].indexOf(15)>=0) { 15 }
total_avg: 0.2672168
Fact: 5.4880217
This benchmarks show that QgsExpression evaluation is between 4 to 6
times
slower than V8. This is much better than I expected, but it's still
factor 4
to 6...
So I think it's worth discussing pros and cons of using V8 as an
expression
engine. I see the following points:
Pros:
-Better performance
-Full Javascript language set included
-Possibility for writing custum functions
Cons:
-New language for expressions
-More fat (3.7MB for libv8.so)
V8 would be a new runtime dependency but would replace the flex and
yacc build
dependencies.
Any other points?
Regards
Pirmin
--
--
Andreas Neumann
Böschacherstrasse 10A
8624 Grüt (Gossau ZH)
Switzerland
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer