Caliper

307 views
Skip to first unread message

Nils Kilden-Pedersen

unread,
Dec 12, 2014, 4:40:49 PM12/12/14
to scala-user

I’ve seen Caliper mentioned many times here, but how is anyone actually running it?

I tried the beta1 on Maven, but that plain doesn’t work. E.g. it doesn’t contain a @Benchmark annotation, but instead has a Benchmark class. I tried extending that, but it did nothing.

Then I checked out the latest source from their git repo and built it. But it throws ClassCastExceptions at startup, because an ImmutableMap<String, String> contains a Boolean, specifically the property "trackAllocations".

This is using the most basic of code, with nothing else set.

So how are you guys using it?

Rex Kerr

unread,
Dec 12, 2014, 6:46:45 PM12/12/14
to Nils Kilden-Pedersen, scala-user
  --Rex

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

√iktor Ҡlang

unread,
Dec 12, 2014, 6:54:18 PM12/12/14
to Rex Kerr, Nils Kilden-Pedersen, scala-user
Konrad keeps an sbt-plugin for it over here: https://github.com/ktoso/sbt-jmh
--
Cheers,

Nils Kilden-Pedersen

unread,
Dec 13, 2014, 12:35:47 AM12/13/14
to Rex Kerr, scala-user

Tried that and immediately ran into this:

Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
    at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:97)
    at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:104)
    at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:242)
    at org.openjdk.jmh.runner.Runner.run(Runner.java:196)

Is that file supposed to be generated or supplied. I’m using Scala with the gradle build, so maybe it’s a problem there?

Rex Kerr

unread,
Dec 13, 2014, 2:32:09 AM12/13/14
to Nils Kilden-Pedersen, scala-user
I can't tell what you tried--JMH generally takes a little fiddling, and I always write the test in Java (calling the Scala methods I want to test).  The reason to use it is because it's good, not because it's easy.

  --Rex

Juha Heljoranta

unread,
Dec 13, 2014, 9:16:31 AM12/13/14
to scala...@googlegroups.com, Nils Kilden-Pedersen
jmh uses Java compile time annotations to generate code. I think the error is
because some code was not generated.

Any way, see this
https://github.com/ktoso/sbt-jmh-seed-activator
(I think grabbing build.sbt and project/plugins.sbt should be enough to get
you going)

Alternatively:
http://typesafe.com/activator/template/sbt-jmh-seed

Writing simple benchmarks work fine using Scala but if you need to exploit
fancier things you probably should write them in Java. For example, I think
its impossible to write inheritance style benchmarks
(http://hg.openjdk.java.net/code-tools/jmh/file/87eea88f9819/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_24_Inheritance.java)
because Scala doesn't have abstract static inner classes.

Cheers,
Juha

Nils Kilden-Pedersen

unread,
Dec 13, 2014, 11:27:33 AM12/13/14
to Rex Kerr, scala-user
On Sat, Dec 13, 2014 at 1:32 AM, Rex Kerr <ich...@gmail.com> wrote:
I can't tell what you tried--JMH generally takes a little fiddling, and I always write the test in Java (calling the Scala methods I want to test).

Yeah, it is a problem with the Gradle plugin. Thanks.
 
  The reason to use it is because it's good, not because it's easy.

That goes without saying.

Jason Nerothin

unread,
Dec 14, 2014, 2:51:18 AM12/14/14
to Nils Kilden-Pedersen, Rex Kerr, scala-user
After an initial test pass, I am finding caliper immensely useful (from Java).

As Juha points out, it does not cover some edgy Java cases. Can someone point out a "hard" toy case from core Scala for me to make a run at? 

For example: Is it also hard to benchmark contra-variance?


scala solist

unread,
Dec 18, 2014, 6:02:58 AM12/18/14
to scala...@googlegroups.com
You probably had stumbled upon documentation for future and yet not released version. It is sufficient to extends com.google.caliper.Benchmark and define methods started with "time" prefix.

I've wrote sbt plugin that does all work for calling caliper but have big unresolved issue. What to do with generated csv file? Write own javafx gui for browsing it or try to incorporate some open source OLAP solution.
Reply all
Reply to author
Forward
0 new messages