java-json-tools/json-schema-core

Pattern validation is awfully slow

sdoeringNew opened this issue · 2 comments

Pattern validation is currently done with Rhino because it is availabe for Java 1.6 and fully supports ECMA 262.

But that makes JSON validation with patterns very slow. The pattern validation for one 10MB String took around 650ms on a very fast machine.

I did some further research and the same validation took 150ms using Java Pattern. But I see the ECMA point and Java Patterns are not.

But.

There is now another script engine in Java implementing ECMA 262. It's called Nashorn. Which is considerably faster. And I mean considerably. It is even faster than using Java Pattern. Validating the 10MB String took 60ms.
Ten times faster than Rhino. And nearly three times faster than Java.

But.

json-schema-core is still a Java 1.6 project and Nashorn is only available on Java 8.

But.

Why not use Rhino as fallback solution in case the Java Runtime does not offer the Nashorn Script Engine?

For the sake of performance.

See pull request: #39

Done three years ago.