Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Performance Improvements


the application is used for virtualization of services (SOAP, REST, JDBC, MQ, ...) generaly for testing of distributed systems (QA can test the system before all the neccessary services are ready and also can easily change behavior of the services and test, how the tested system works with different conditions).
Very simply said our application recieves request message and have to generate and send response message. One of the ways, how the application can modify the response is to modify or partially create it in using JavaScript. And here is the place, where ClearScript is used. The message is stored in a tree structure and user can modify or change any value in the tree and I have to know, what exactly did the user set in the tree not only what did he changed, I have also to know, if user sets some value that was already there. Thas why the simple diff of the original tree and the result of the script execution is not good enought. I have to map the tree to the ClearScript and trace all the objects set into it.
Some scripts are fast (run few ms) but not all of them. We have also script, where millisons of objects are created and added to the tree in for-cycle.

I've already tried to use V8ScriptEngineFlags.DisableGlobalMembers but it did wasn;t faster. In what cases should it help?

After fixing the performance issues I've found in ClearScript, profiler shows me weak places in my app. Is some better way, how can I do this calls faster?

1) Getting property names from object created in JavaScript:
2) Check if the object is an array:
..just once:
  isArrayFunction = clearScriptEngine.V8ScriptEngine.Evaluate("(function (x) { return x instanceof Array; })");
..and than use lot of times:
3) Getting the property value:
dynamicObject.TryGetMember(new Binder(propertyName, false), out propertyValue)
I've also tried to get property value using CallSite. But it was slower even when I was chaching the CallSites.

Thanks, Libor.

Viewing all articles
Browse latest Browse all 2297