/*
 * JBoss, Home of Professional Open Source
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.cache.optimistic;

/**
 *
 * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 */
public class RunAll
{
    public static void main(String[] args)
    {

        Object[] results = new Object[4];

        OptimisticPerfTestBase test = new LocalPessimisticTest();
        try
        {
            test.runTests();
            results[0] = test.results;
        }
        catch (Exception e)
        {
            results[0] = e;
        }

        test = new LocalPessimisticCLTest();
        try
        {
            test.runTests();
            results[1] = test.results;
        }
        catch (Exception e)
        {
            results[1] = e;
        }

        test = new LocalTest();
        try
        {
            test.runTests();
            results[2] = test.results;
        }
        catch (Exception e)
        {
            results[2] = e;
        }

        test = new LocalCLTest();
        try
        {
            test.runTests();
            results[3] = test.results;
        }
        catch (Exception e)
        {
            results[3] = e;
        }

        printReport( results );
    }

    private static void printReport( Object[] results )
    {
        // print header.
        System.out.println("Test Name, Time of Test, Num Loops, Num Threads, Overall Total Time, Overall Num Ops, Overall Avg Time, Put Total Time, Put Num Ops, Put Avg Time, Get Total Time, Get Num Ops, Get Avg Time, Remove Total Time, Remove Num Ops, Remove Avg Time");

        for (int i=0; i< results.length; i++)
        {
            if (results[i] instanceof Exception)
                ((Exception) results[i]).printStackTrace();
            else
            {
                OptimisticPerfTestBase.Results r = (OptimisticPerfTestBase.Results) results[i];
                System.out.println(r.toCSVString());
            }

        }

    }
}
