/* --------------------------------------------------------- *
* __________ D E L T A S C R I P T *
* (_________() *
* / === / - A fast, dynamic scripting language *
* | == | - Version 4.13.11.0 *
* / === / - Developed by Adam R. Nelson *
* | = = | - 2011-2013 *
* / === / - Distributed under GNU LGPL v3 *
* (________() - http://github.com/ar-nelson/deltascript *
* *
* --------------------------------------------------------- */
package com.sector91.delta.script.profiling;
import com.sector91.delta.script.DScriptContext;
import com.sector91.delta.script.DeltaScript;
import com.sector91.delta.script.instrs.DSInstr;
import com.sector91.delta.script.objects.DS_Scope;
public class FibonacciProfiler
{
public static void main(String[] args) throws Exception
{
DScriptContext context = new DScriptContext();
DS_Scope scope = context.createScope();
DeltaScript.eval("func fib(n); if n < 2, 1, else, fib(n-1) + fib(n-2), xi; xf", "Fibonacci Method Def", scope, context);
DSInstr script = DeltaScript.compile("..print(fib(35))");
System.out.println("Primer run...");
DeltaScript.exec(script, scope, context);
System.out.println("Actual run...");
long mark = System.currentTimeMillis();
DeltaScript.exec(script, scope, context);
long total = System.currentTimeMillis() - mark;
System.out.println("Total time: " + total);
}
}