I'm having low Rhino performance issues while executing Rhino code on Android real device.
The Rhino context is initiated with a string which represents big JSON object, the total string size is around 120K, to test code performance we wrote a few instrumental tests to check the code performance, however, we are getting not clear result the same code, with the same parameters shows absolutely different results between tests and sample app.
The test performance 10 times faster than the same code is executed as an instrumental test then on it's running as part of the sample app on the same device (G5). BTW the android emulator also shows good performance result.
the code is pretty simple
private void init(String jFfunctionsDeclaration) throws ScriptInitException {
StringBuilder ruleEngineContextBuffer = new StringBuilder();
//create a JSON object in the string representation, later Rhino context will be initialized with this string
for (Map.Entry<String, String> e : scriptObjects.entrySet()) {
String key = e.getKey();
String value = e.getValue();
ruleEngineContextBuffer.append("\nvar ");
ruleEngineContextBuffer.append(key);
ruleEngineContextBuffer.append(" = "); // append(" = JSON.parse(");
ruleEngineContextBuffer.append(value);
}
// create and enter safe execution context to prevent endless loop or deadlock in JS
// because Rhino input it provided from outside
SafeContextFactory safeContextFactory = new SafeContextFactory();
rhino = safeContextFactory.makeContext().enter();
try {
// the fisrt init step, init Rhino cotext with JS utils methods
// functions input is the list of JS functions
sharedScope = rhino.initStandardObjects();
rhino.evaluateString(sharedScope, functions, "<init1>", 1, null);
String str = ruleEngineContextBuffer.toString();
long startContextInit = System.currentTimeMillis();
rhino.evaluateString(sharedScope, str, "<init2>", 1, null);
long totalContextInit = System.currentTimeMillis() - startContextInit;
Log.d(TAG, "Rhino context init duration = " + totalContextInit);
} catch (Throwable e) {
throw new ScriptInitException("Javascript shared scope initialization error: " + e.getMessage());
}
}
could someone explain me this mystery, thanks? The problem that all my considerations whether to integrate the Rhino lib into the production app were based on these results which in fact are wrong.
--
You received this message because you are subscribed to the Google Groups "mozilla-rhino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-rhino+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-rhin...@googlegroups.com.