You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the below C# code snippet to measure the performance of simple java script expression execution.
int COUNT = 10000;
// Do a timing test, across many iterations, for an expression
object result1 = null;
var ctx = new CSharp.Context();
DateTime begin = DateTime.Now;
for (int i = 0; i < COUNT; i++)
{
result1 = ctx.Execute("3 * 20;");
}
DateTime end = DateTime.Now;
TimeSpan x = new TimeSpan(end.Ticks - begin.Ticks);
Console.WriteLine("Expression: Number of seconds for " + COUNT + " expressions: " + x.TotalSeconds);
It took 143 seconds to run 10,000 iterations. At the same time if put the same expression into a file and call ctx.ExecuteFile("C:\test.js") and it took only 600 ms. Any thoughts or suggestions is helpful.
The text was updated successfully, but these errors were encountered:
I haven't looked at the Execute() or ExecuteFile() source code, but perhaps ExecuteFile() caches the AST tree for the parsed test.js file and uses the cache on each execution while with Execute there is no caching mechanism? It should be possible to just do a simple SHA1 of the code within Execute() and use that as a key for the cache.
Unless I've got it all wrong and there is no cache involved, of course.
I am using the below C# code snippet to measure the performance of simple java script expression execution.
It took 143 seconds to run 10,000 iterations. At the same time if put the same expression into a file and call ctx.ExecuteFile("C:\test.js") and it took only 600 ms. Any thoughts or suggestions is helpful.
The text was updated successfully, but these errors were encountered: