1

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.

1 Answers1

0

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.

Community
  • 1
  • 1
maaartinus
  • 44,714
  • 32
  • 161
  • 320
  • I've tried variations on Tutorial (Tutorial$Benchmark1.class and so on) and none of them work. I've attempted un-nesting the class as well. For the record, the jar and the compiled class are sharing a directory. The second command results in "could not find the main class." I don't understand why Tutorial is apparently invisible... is it looking exclusively in the jar? How can I ensure that it's on the classpath? – Kristine Richard Feb 04 '14 at 15:37
  • Actually, got it. You were right, it was a classpath issue. Ended up doing `export CLASSPATH=/path/to/jar:.` and running `java com.google.caliper.runner.CaliperMain Tutorial` from the directory including the .class files... It's finding the class fine. It still doesn't work, mind, as it crashes with no output, but at it's technically running. – Kristine Richard Feb 04 '14 at 15:53
  • @KristineRichard: No output at all? That's strange. Maybe `-v` could help, no idea. I couldn't find the tutorial you're using, so I can't try it out. Maybe you could create a [SSCCE](http://sscce.org) the form of a ZIP file? – maaartinus Feb 04 '14 at 17:09
  • Well, not "none at all" (sorry) but after downloading and rebuilding the newest revision I actually get some results - I think the issue had been fixed in January. There is a problem with crashes during allocation measurement but the runtime testing works fine so far and that's enough for me at the moment. I'm no longer held up, and I submitted an issue re: other crashes. – Kristine Richard Feb 04 '14 at 17:54