Skip to content

ClearScript V8 Running as a Calculation Engine #593

Answered by ClearScriptLib
ninlar asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ninlar,

I probably don't want to have to use a new V8ScriptEngine. It is probably better to compile once, then invoke the function over and over with the different arguments for each calculation.

Yes. If a script is to be executed many times, spinning up a new engine for each invocation is almost always the wrong way to go. Invoking an existing script function is the fastest and often the best way.

That being said, if one calculation writes data to a global object, another instance could overwrite it, so I they should probably be isolated.

Using separate engines is the only way to prevent scripts from sharing a global object. With V8, you have several options:

  1. Use engines with pr…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ninlar
Comment options

@ninlar
Comment options

@ClearScriptLib
Comment options

Answer selected by ninlar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants