-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self-executing function changing dramatically the execution time #68
Comments
That's very strange. I can't take a look right now, sorry, I'm on holiday :-) But I'll take a look when I get back. |
I tried it, but both the self-executing and non-self-executing function took about the same amount of time. Can you clarify exactly what code you were using when you experienced the slow execution and/or the stack overflow exception? |
Hi @paulbartrum, I can reproduce the StackOverflowException and the long run time just by creating a new ScriptEngine and executing the code from @rodrigoroma without the self-executing function expression, using Jurassic from the current I have created a repro with commit kpreisser@49dda06. When I run this project on a 64-Bit machine (using VS 2015), I'm getting a StackOverflowException. Thanks! |
Hi @paulbartrum and @kpreisser, I've also created a simple program to reproduce this issue (it's attached). My environment is Visual Studio Community 2015 in Windows 10 Pro (64 bits version) using the latest version of Jurassic available in NuGet (I've just created a new Console Application and ran My guess is that the long time has something to do with global variables because if I put the declaration of "a" out of the self-executing function (that is, in the global scope), it also takes a long time.
Thanks! |
Accessing global variables is quite a bit slower than accessing local variables. But I'm not sure that's the problem here. Separating out the compilation and the execution: ScriptEngine engine = new ScriptEngine();
var compiledCode = engine.Compile(new StringScriptSource(generateCode(false)));
compiledCode.Execute();
|
Ok, thanks again for your attention! |
Oh no, I'm wrong, the elapsed time is in the execution.
That means it's likely to be a problem with the codegen for reading or writing a global variable (or both). |
I made some small changes to the Jurassic code, I hope @paulbartrum understanding。 |
Hi,
the first thing that I want to say is congratulations for your excellent work on Jurassic!
I've got an interesting case that I don't know if it is the normal behavior, a bug or if I'm doing something wrong.
Take the following code as an example:
The above code runs in approximately 80ms but if I remove the self-executing function (lines 1 and 2004), it runs in something about 900ms.
If the "a++;" instruction is repeated 10k times instead of 2k, with the self-executing function it takes 120ms and without this function it gives "An unhandled exception of type 'System.StackOverflowException' occurred in Jurassic.dll"
Before running this Javascript code I do some other stuffs in the Jurassic engine but I don't think it's relevant. I can provide further details if necessary.
The text was updated successfully, but these errors were encountered: