You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Artem Barger (JIRA)" <ji...@apache.org> on 2016/08/10 11:57:20 UTC
[jira] [Comment Edited] (RNG-4) Add benchmark to compare
performance of generating a sequence of number values.
[ https://issues.apache.org/jira/browse/RNG-4?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15415161#comment-15415161 ]
Artem Barger edited comment on RNG-4 at 8/10/16 11:56 AM:
----------------------------------------------------------
Was toying w/ API's and created following benchmark as well:
{code:java}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.rng;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit;
/**
* Benchmark which leverages Quasi Monte-Carlo method to numerically compute
* integral sin(cos(x)) for interval [0..1].
*/
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class QuasiMonteCarloIntegralTestPerformance extends AbstractTestPerformance {
/**
* Number of random values to generate.
*/
@Param({"1000000"})
long numPoints;
@Benchmark
public void integral(Sources sources, Blackhole bh) {
double result = 0;
for (int i = 0; i < numPoints; i++) {
result += Math.sin(Math.cos(sources.provider.nextDouble()));
}
result /= numPoints;
bh.consume(result);
}
}
{code}
Uses quasi monte carlo method to numerically compute integral of sin(cos(x))dx in interval [0..1].
was (Author: c0rwin):
Was toying w/ API's and created following benchmark as well:
{code:java}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.rng;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit;
/**
* Benchmark which leverages Quasi Monte-Carlo method to numerically compute
* integral sin(cos(x)) for interval [0..1].
*/
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class QuasiMonteCarloIntegralTestPerformance extends AbstractTestPerformance {
/**
* Number of random values to generate.
*/
@Param({"1000000"})
long numPoints;
@Benchmark
public void integral(Sources sources, Blackhole bh) {
double result = 0;
for (int i = 0; i < numPoints; i++) {
result += Math.sin(Math.cos(sources.provider.nextDouble()));
}
result /= numPoints;
bh.consume(result);
}
}
{code}
> Add benchmark to compare performance of generating a sequence of number values.
> -------------------------------------------------------------------------------
>
> Key: RNG-4
> URL: https://issues.apache.org/jira/browse/RNG-4
> Project: Commons RNG
> Issue Type: Bug
> Reporter: Artem Barger
> Attachments: RNG-4.patch, jmh-result.json
>
>
> There is a set on random source providers implemented in the project, here I'd like to suggest creating a benchmark to actually provide such an experiment.
> Once having such test everybody will be able to compare and pick more suitable for use case.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)