package org.lucci.madhoc.script;
import org.lucci.config.TypedConfiguration;
import org.lucci.madhoc.simulation.MadhocSimulation;
import org.lucci.madhoc.util.Utilities;
import org.lucci.util.Timer;
public class BenchIterationDuration
{
public static void main(String[] args)
throws Throwable
{
System.out.println();
System.out.println("Calcultes the time required for running one iteration of the simulation process as the simulated surface increases.");
System.out.println();
System.out.println("edge (m)\ttime (ms)");
System.out.println("--------\t---------");
TypedConfiguration config = Utilities.getConfiguration(args);
int n = 100;
for (int edge = 200;; edge *= 1.5)
{
int surface = edge * edge;
surface -= surface % 10000;
edge = (int) Math.sqrt(surface);
config.getRelation().remove("simulation_area_surface");
config.add("simulation_area_surface", String.valueOf(surface));
MadhocSimulation simulation = Utilities.getSimulation(config);
Timer timer = new Timer();
for (int i = 0; i < n; ++i)
{
simulation.iterate();
}
double time = timer.getElapsedMillis() / n;
System.out.println(edge + "\t\t" + time);
}
}
}