operations/second

37 views
Skip to first unread message

Peter Veentjer

unread,
Dec 8, 2013, 1:10:52 AM12/8/13
to junit-be...@googlegroups.com
Hi Guys,

is it possible to get the operations/second?

E.g.

   @Test
    public void get() throws Exception {
        for(int k=0;k<500000;k++){
            distributedAtomicLong.get();
        }
    }

The running time is known, but I'm not interested in the running time; I want to know the number of operations/second.

I know that currently this is not possible to measure because the 500000 is hardcoded and not visible from the outside, but if I could say something like:

 @Test
    public void get() throws Exception {
       int iterations = 500000;
       benchmarkRun.iterations(iterations); 
       for(int k=0;k<iterations;k++){
            atomicLong.get();
        }
    }

Then the information is known to the benchmarking framework.

WDYT?

Peter.

Dawid Weiss

unread,
Dec 8, 2013, 2:20:55 PM12/8/13
to junit-benchmarks
Not directly, but you can divide the number of loop iterations by the
total test execution time ;)

This is a severely broken benchmark, by the way -- it'll probably be
optimized in a way that no longer reflects realistic use cases.

If you care about measuring nano-second ops, I'd suggest that you look
at JMH, here:
http://openjdk.java.net/projects/code-tools/jmh/

Dawid
> --
> You received this message because you are subscribed to the Google Groups
> "JUnitBenchmarks: Performance Benchmarking for JUnit4" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to junit-benchmar...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Peter Veentjer

unread,
Dec 8, 2013, 2:37:16 PM12/8/13
to junit-be...@googlegroups.com
Hi David,

thanks for your comment.

Dividing the operations by time I already came up with myself, but I would like it to be not just some information that is logged.

PS: This is not an AtomicLong from java, but a distributed atomic long from hazelcast. The code can't be eliminated by the compiler
since internal state changes are happening (e.g. statistics). 

Dawid Weiss

unread,
Dec 8, 2013, 2:41:57 PM12/8/13
to junit-benchmarks
> Dividing the operations by time I already came up with myself, but I would
> like it to be not just some information that is logged.

Unfortunately it's not possible out of the box. I can't remember if
Caliper had such an option -- I don't think so (it scaled the number
of test repetitions automatically, but never showed it explicitly as
far as I can remember).

This project isn't really best suited for measuring such fine-grained
operations. This requires a freshly spawned JVM, with no previous
statistics, etc. Look at caliper or jmh, I think they'd be better
matches.

Dawid
Reply all
Reply to author
Forward
0 new messages