Search in sources :

Example 1 with TestResults

use of jmbench.tools.TestResults in project Java-Matrix-Benchmark by lessthanoptimal.

the class MemoryTest method evaluate.

@Override
public TestResults evaluate() {
    Random rand = new Random(randomSeed);
    BenchmarkMatrix[] inputs = gen != null ? gen.createInputs(factory, rand, size) : null;
    double[] mod = null;
    if (gen != null) {
        mod = new double[inputs.length];
        for (int i = 0; i < inputs.length; i++) {
            mod[i] = inputs[i].get(0, 0);
        }
    }
    MatrixProcessorInterface operation = createAlgorithm();
    // see if the operation is supported
    if (operation == null) {
        return new Results(-1);
    }
    long start = System.currentTimeMillis();
    // output is null since that might require creating new memory, which isn't strictly part of th test
    operation.process(inputs, null, N);
    long stop = System.currentTimeMillis();
    if (gen != null) {
        for (int i = 0; i < inputs.length; i++) {
            if (mod[i] != inputs[i].get(0, 0))
                throw new RuntimeException("Input modified! Input " + i);
        }
    }
    // the application exits
    synchronized (this) {
        try {
            wait(300);
        } catch (InterruptedException e) {
        }
    }
    return new Results(stop - start);
}
Also used : MatrixProcessorInterface(jmbench.interfaces.MatrixProcessorInterface) Random(java.util.Random) TestResults(jmbench.tools.TestResults) BenchmarkMatrix(jmbench.interfaces.BenchmarkMatrix)

Example 2 with TestResults

use of jmbench.tools.TestResults in project Java-Matrix-Benchmark by lessthanoptimal.

the class RuntimeBenchmarkLibrary method convertToDoubleList.

private static List<Double> convertToDoubleList(List<TestResults> l) {
    List<Double> ret = new ArrayList<Double>(l.size());
    for (TestResults aL : l) {
        double val = ((RuntimeMeasurement) aL).getOpsPerSec();
        ret.add(val);
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) TestResults(jmbench.tools.TestResults)

Example 3 with TestResults

use of jmbench.tools.TestResults in project Java-Matrix-Benchmark by lessthanoptimal.

the class StabilityBenchmarkLibrary method evaluateOperation.

public StabilityTrialResults evaluateOperation(StabilityTestBase e) {
    fatalError = null;
    e.setRandomSeed(config.randomSeed);
    EvaluatorSlave.Results results = spawnChild ? tools.runTest(e, 1) : tools.runTestNoSpawn(e, 1);
    slaveMemoryMegaBytes = tools.getAllocatedMemoryInMB();
    if (results == null) {
        logStream.println("*** WTF runTest returned null = " + e.getTestName());
        fatalError = FatalError.RETURNED_NULL;
    } else if (results.failed == EvaluatorSlave.FailReason.USER_REQUESTED) {
        logStream.println("    Slave was killed by the user/OS.  Stopping the benchmark.  op = " + e.getTestName());
        logStream.println("    error message: " + results.detailedError);
        System.out.println("  Slave was killed by the user/OS.  Stopping the benchmark.");
        System.out.println("    error message: " + results.detailedError);
        System.exit(0);
    } else if (results.failed == EvaluatorSlave.FailReason.OUT_OF_MEMORY) {
        System.out.println("  Not enough memory given to slave. ");
        logStream.println("Not enough memory for op.  " + e.getTestName() + " memory " + tools.getAllocatedMemoryInMB());
    } else {
        if (results.failed != null) {
            fatalError = FatalError.MISC;
            if (results.failed == EvaluatorSlave.FailReason.TOO_SLOW) {
                logStream.println("    Slave: Case too slow = " + e.getTestName());
            } else if (results.failed == EvaluatorSlave.FailReason.FROZEN) {
                logStream.println("    Slave: Frozen = " + e.getTestName());
                fatalError = FatalError.FROZE;
            } else {
                logStream.println("    Slave: Case failed = " + results.failed + " op = " + e.getTestName() + " memory " + tools.getAllocatedMemoryInMB());
                if (results.detailedError != null) {
                    logStream.println(results.detailedError);
                }
            }
        }
    }
    // see if something very bad happened
    if (fatalError != null)
        return null;
    // collect all the results and return them
    StabilityTrialResults all = new StabilityTrialResults();
    for (TestResults t : results.getResults()) {
        StabilityTrialResults r = (StabilityTrialResults) t;
        all.addResults(r);
    }
    return all;
}
Also used : EvaluatorSlave(jmbench.tools.EvaluatorSlave) TestResults(jmbench.tools.TestResults)

Aggregations

TestResults (jmbench.tools.TestResults)3 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 BenchmarkMatrix (jmbench.interfaces.BenchmarkMatrix)1 MatrixProcessorInterface (jmbench.interfaces.MatrixProcessorInterface)1 EvaluatorSlave (jmbench.tools.EvaluatorSlave)1