javacaliper

Running caliper commandline


OK, again having some problems with caliper.

I am now running on Linux, trying to use the beta snapshot. I am attempting to run Google's caliper via commandline using just the jar. (Beta snapshot)

I do not have access to maven on this machine, and installing it is out of the question. I would just like to use a jar and, maybe once this is working, I can write up a script or something.

Here is what I am doing:

1. Using small example Benchmark:

import com.google.caliper.Benchmark;

public class Tutorial {

  public static class Benchmark1 {
    @Benchmark void timeNanoTime(int reps) {
      for (int i = 0; i < reps; i++) {
        System.nanoTime();
      }
    }
  }
}

2. Compile with javac -cp caliper-1.0-beta-SNAPSHOT-all.jar Tutorial.java

3. (Attempt to) run with

java -cp caliper-1.0-beta-SNAPSHOT-all.jar com.google.caliper.runner.CaliperMain Tutorial.Benchmark1, receive message Benchmark class not found: Tutorial.Benchmark1.

I've tried to work this out from bits and pieces of information from various sources but I am really having a heck of a time with this. I would appreciate any input.


Solution

  • I believe you really need no maven, this should work.

    Your own class doesn't get found and I think it's a problem of your classpath. As they're usually more problem with nested classes try simply

    java -cp caliper-1.0-beta-SNAPSHOT-all.jar com.google.caliper.runner.CaliperMain Tutorial
    

    If the message changes to something like "class contains no benchmarks", then you'll know more. If you insists on using nested class, you may need to call Tutorial$Benchmark1 (unprobable, but possible; java class naming is sick).

    Please try also

    java -cp caliper-1.0-beta-SNAPSHOT-all.jar Tutorial.Benchmark1
    

    to see if your class lies on the classpath (the message should change to something like "no main method").

    See also this older post.