Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Benchmarks

0
0
I notice the bottleneck is here
var uniqueName = documentNameManager.GetUniqueName(documentName, "Script Document");
It is generating a new name even the same script is being executed twice. If I changed it to
uniqueName = code.GetHashCode().ToString() // Just an example to create a unique code based on the script
If the same script is being executed twice, it will run extremely fast and efficient (Should have the same performance as compiling the script).

I think Javascript.NET has similar optimization because the first code below runs almost 8~10x slower than the second one
for (int i = 0; i < 10000; i++)
{
      engine.Run("Math.random() + " + i);
}

for (int i = 0; i < 10000; i++)
{
      engine.Run("Math.random()");
}

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images