1

This is the benchmark i can run over the COMMAND LINE with "java -jar target/benchmarks.jar":

public class MyBenchmark {

@Benchmark
public void testMethod() throws IOException {

    Logger log = LoggerFactory.getLogger(MyBenchmark.class);

        //number of rows and columns in the input pictures
        final int numRows = 28;
        final int numColumns = 28;
        int outputNum = 10; // number of output classes
        int batchSize = 64; // batch size for each epoch
        int rngSeed = 123; // random number seed for reproducibility
        int numEpochs = 15; // number of epochs to perform
        double rate = 0.0015; // learning rate

        //Get the DataSetIterators:
        DataSetIterator mnistTrain = new MnistDataSetIterator(batchSize, true, rngSeed);
        DataSetIterator mnistTest = new MnistDataSetIterator(batchSize, false, rngSeed);


        log.info("Build model....");

        File locationToSave = new File("dasGespModell.zip");

        MultiLayerNetwork model = ModelSerializer.restoreMultiLayerNetwork(locationToSave);
        model.init();
        //model.setListeners(new ScoreIterationListener(5));  //print the score with every iteration


        log.info("Evaluate model....");
        Evaluation eval = model.evaluate(mnistTest);

        log.info(eval.stats());
        log.info("****************Example finished********************");


}

}

But I want to measure this code explicit on my GPU and my CPU and this is only possible, when I change the dependencies in my pom.xml and run the code when pushing the run button and not putting "java -jar target/benchmarks.jar" in the terminal.

Any ideas?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • You can probably use Maven profiles to switch the dependencies. See https://stackoverflow.com/questions/166895/different-dependencies-for-different-build-profiles – GreyBeardedGeek Mar 20 '21 at 13:14
  • _before_ you do anything, please consider to give the jmh examples a look. Specifically this `void testMethod()....` is a red flag - as you will find out in one of the examples – Eugene Mar 22 '21 at 01:07

0 Answers0