Skip to content

Fast and lightweight expression evaluator for Java

License

Notifications You must be signed in to change notification settings

naivesound/expr-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jexpr

Build Status

Fast and lightweight expression evaluator for Java. The whole evaluator is only one class of ~500LOC.

Expr.Builder builder = new Expr.Builder();

Map<String, Variable> vars = .....
Map<String, Func> funcs = ....

vars.get("x").set(42);
Expr e = builder.parse("y=2+f(x)", vars, funcs);
float result = e.eval();
float y = vars.get("y").eval();

Performance

parse 1: 56443.277
parse 10: 276689.75
parse 100: 2234274.5
eval 1: 1249.1752
eval 10: 3833.1233
eval 100: 6461.009

This means that a large expression of ~3k characters using variables, assignments and functions takes 2ms to parse (compile) and 6.4us to evaluate.

About

Fast and lightweight expression evaluator for Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages