(in ExampleApp7.java)
import org.vcssl.nano.VnanoEngine;
import org.vcssl.nano.VnanoException;
import java.util.Map;
import java.util.HashMap;
public class ExampleApp7 {
// The number of the repetitions of the executions.
static final int REPETITION_COUNT = 100000000;
// A plug-in providing a variable "x".
public static class VariablePlugin {
public double x;
}
public static void main(String[] args) throws VnanoException {
//Create a scripting engine of Vnano (= Vnano Engine).
VnanoEngine engine = new VnanoEngine();
// Instantiate the plug-in providing a variable "x", and connect it to the engine.
VariablePlugin plugin = new VariablePlugin();
engine.connectPlugin("VariablePlugin", plugin);
// To reduce overheads, disable "automatic-activation" feature.
Map optionMap = new HashMap();
optionMap.put("AUTOMATIC_ACTIVATION_ENABLED", false);
// Define the content of the expression (or script) to be executed.
String expression = " x * 0.5 + 3.2 ; " ;
// Declare a variable for taking summation of the results of the repetitive executions.
double sum = 0.0;
// Activate the engine manually.
engine.activate();
// Store the time at the beginning of the repetitive executions
long beginTime = System.nanoTime();
// Execute the expression (or script) for REPETITION_COUNT times repetitively.
for (int i=0; i