NeilFraser / JS-Interpreter

A sandboxed JavaScript interpreter in JavaScript.
Apache License 2.0
1.98k stars 355 forks source link

Performance #227

Closed yang closed 2 years ago

yang commented 2 years ago

Thank you for sharing this library!

Would you happen to have handy any rough ballparks around what to expect performance-wise? Thanks!

NeilFraser commented 2 years ago

Yes, in the documentation it states:

The interpreter is not particularly efficient. It currently runs about 200 times slower than native JavaScript.

However, this is hard to properly quantify since the performance profiles are completely different. For example, in JS-Interpreter regular expressions (for example) are almost exactly as fast as in native JavaScript, whereas basic loops (for example) are much slower. So there is no single multiplier that describes the performance difference.

Performance does remain an important consideration, and periodic improvements are made in this regard. But security is the primary consideration, followed by simplicity.