Average time computation just prints out "10??"
David Karr
davidmichaelkarr at gmail.com
Mon Oct 1 16:27:25 UTC 2018
On Mon, Oct 1, 2018 at 8:32 AM Aleksey Shipilev <shade at redhat.com> wrote:
> On 10/01/2018 05:27 PM, David Karr wrote:
> > That doesn't really seem like a clear answer, but in any case, I changed
> the class annotation,
> > adding a @Warmup annotation. I let the run finish completely. Every
> statistic was "s/op", and had
> > the encoded characters.
> >
> > If it matters, here's the entire skeleton of the class:
> >
> > @Measurement(timeUnit = TimeUnit.MICROSECONDS)
> > @Warmup(timeUnit = TimeUnit.MICROSECONDS)
> > public class MyBenchmark {
> > @Benchmark
> > @BenchmarkMode(value = { Mode.AverageTime})
> > public void createBigDecimalFromFormattedDouble() {
> > ...
> > }
> >
> > @Benchmark
> > @BenchmarkMode(value = { Mode.AverageTime})
> > public void createBigDecimalFromDoubleWithScale() {
> > ...
> > }
> > }
>
> Time units can also be overridden by command line option and/or Java API
> runner.
>
> Please show the complete example, together with the code that runs it?
>
There's hardly anything else here of note. On the command line, I run "mvn
clean install" and then "java -jar target/benchmarks.jar".
I'm certain it doesn't matter, but here are the two method bodies:
public void createBigDecimalFromFormattedDouble() {
DecimalFormat df = new DecimalFormat("##0.00");
new BigDecimal(df.format(47.0));
new BigDecimal(df.format(324.6));
new BigDecimal(df.format(4.3));
new BigDecimal(df.format(123.93));
new BigDecimal(df.format(997.01));
}
public void createBigDecimalFromDoubleWithScale() {
DecimalFormat df = new DecimalFormat("##0.00");
new BigDecimal(47.0).setScale(2, BigDecimal.ROUND_HALF_UP);
new BigDecimal(324.6).setScale(2, BigDecimal.ROUND_HALF_UP);
new BigDecimal(4.3).setScale(2, BigDecimal.ROUND_HALF_UP);
new BigDecimal(123.93).setScale(2, BigDecimal.ROUND_HALF_UP);
new BigDecimal(997.01).setScale(2, BigDecimal.ROUND_HALF_UP);
}
> -Aleksey
>
>
>
>
More information about the jmh-dev
mailing list