Moved benchmarks to "internal" package.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bfae8665 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bfae8665 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bfae8665 Branch: refs/heads/ignite-2324 Commit: bfae8665230642fe558aad6a9c8b0b14f46a8cba Parents: 80d244d Author: vozerov-gridgain <[email protected]> Authored: Wed Jan 27 15:53:54 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Wed Jan 27 15:53:54 2016 +0300 ---------------------------------------------------------------------- .../benchmarks/jmh/cache/PutBenchmark.java | 170 ------------------- .../ignite/benchmarks/model/IntValue.java | 91 ---------- .../benchmarks/jmh/cache/PutBenchmark.java | 170 +++++++++++++++++++ .../internal/benchmarks/model/IntValue.java | 91 ++++++++++ 4 files changed, 261 insertions(+), 261 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/bfae8665/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java deleted file mode 100644 index 8ccaf81..0000000 --- a/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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.ignite.benchmarks.jmh.cache; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.Ignition; -import org.apache.ignite.benchmarks.model.IntValue; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.OutputTimeUnit; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.annotations.Threads; -import org.openjdk.jmh.annotations.Warmup; -import org.openjdk.jmh.runner.Runner; -import org.openjdk.jmh.runner.options.Options; -import org.openjdk.jmh.runner.options.OptionsBuilder; - -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.TimeUnit; - -/** - * Put benchmark. - */ -@SuppressWarnings({"unchecked", "unused", "FieldCanBeLocal"}) -@State(Scope.Benchmark) -@BenchmarkMode(Mode.Throughput) -@OutputTimeUnit(TimeUnit.SECONDS) -@Warmup(iterations = 10) -@Measurement(iterations = 120) -@Fork(1) -public class PutBenchmark { - /** First Ignite instance. */ - private static Ignite ignite1; - - /** Second Ignite instance. */ - private static Ignite ignite2; - - /** Target cache. */ - private static IgniteCache<Integer, IntValue> cache1; - - /** Items count. */ - private static final int CNT = 100000; - - /** IP finder shared across nodes. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** - * Set up routine. - * - * @throws Exception If failed. - */ - @Setup - public static void setup() throws Exception { - ignite1 = Ignition.start(config("node1")); - ignite2 = Ignition.start(config("node2")); - - cache1 = ignite1.cache(null); - - IgniteDataStreamer<Integer, IntValue> dataLdr = ignite1.dataStreamer(cache1.getName()); - - for (int i = 0; i < CNT; i++) - dataLdr.addData(i, new IntValue(i)); - - dataLdr.close(); - - System.out.println("Cache populated."); - } - - /** - * Tear down routine. - * - * @throws Exception If failed. - */ - @TearDown - public static void tearDown() throws Exception { - Ignition.stopAll(true); - } - - /** - * Create configuration. - * - * @param gridName Grid name. - * @return Configuration. - */ - private static IgniteConfiguration config(String gridName) { - IgniteConfiguration cfg = new IgniteConfiguration(); - - cfg.setGridName(gridName); - - cfg.setLocalHost("127.0.0.1"); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - cfg.setDiscoverySpi(discoSpi); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setName(null); - cacheCfg.setCacheMode(CacheMode.PARTITIONED); - cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); - cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); - cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC); - cacheCfg.setBackups(1); - - cfg.setCacheConfiguration(cacheCfg); - - return cfg; - } - - /** - * Test PUT operation. - * - * @throws Exception If failed. - */ - @Benchmark - @Threads(4) - public void testPut() throws Exception { - int key = ThreadLocalRandom.current().nextInt(CNT); - - cache1.put(key, new IntValue(key)); - } - - /** - * Runner. - * - * @param args Arguments. - * @throws Exception If failed. - */ - public static void main(String[] args) throws Exception { - // Use the following additional options to record JFR dump: - // "-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder", "-XX:StartFlightRecording=delay=20s,duration=60s,filename=ignite-put_bench.jfr" - - String[] jvmArgs = new String[] { "-Xms4g", "-Xmx4g" }; - - Options opts = new OptionsBuilder().include(PutBenchmark.class.getSimpleName()).jvmArgs(jvmArgs).build(); - - new Runner(opts).run(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/bfae8665/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java ---------------------------------------------------------------------- diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java b/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java deleted file mode 100644 index 5d29d33..0000000 --- a/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.ignite.benchmarks.model; - -import org.apache.ignite.binary.BinaryObjectException; -import org.apache.ignite.binary.BinaryReader; -import org.apache.ignite.binary.BinaryWriter; -import org.apache.ignite.binary.Binarylizable; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; - -/** - * Simple wrapped int value. - */ -public class IntValue implements Externalizable, Binarylizable { - /** Value. */ - private int val; - - /** - * Default constructor. - */ - public IntValue() { - // No-op. - } - - /** - * Constructor. - * - * @param val Value. - */ - public IntValue(int val) { - this.val = val; - } - - /** - * @param val Value. - */ - public void value(int val) { - this.val = val; - } - - /** - * @return Value. - */ - public int value() { - return val; - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - val = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - out.writeInt(val); - } - - /** {@inheritDoc} */ - @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { - writer.writeInt("id", val); - } - - /** {@inheritDoc} */ - @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { - val = reader.readInt("id"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Value [id=" + val + ']'; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/bfae8665/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/PutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/PutBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/PutBenchmark.java new file mode 100644 index 0000000..aa04389 --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/PutBenchmark.java @@ -0,0 +1,170 @@ +/* + * 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.ignite.internal.benchmarks.jmh.cache; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.Ignition; +import org.apache.ignite.internal.benchmarks.model.IntValue; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheRebalanceMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; + +/** + * Put benchmark. + */ +@SuppressWarnings({"unchecked", "unused", "FieldCanBeLocal"}) +@State(Scope.Benchmark) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@Warmup(iterations = 10) +@Measurement(iterations = 120) +@Fork(1) +public class PutBenchmark { + /** First Ignite instance. */ + private static Ignite ignite1; + + /** Second Ignite instance. */ + private static Ignite ignite2; + + /** Target cache. */ + private static IgniteCache<Integer, IntValue> cache1; + + /** Items count. */ + private static final int CNT = 100000; + + /** IP finder shared across nodes. */ + private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** + * Set up routine. + * + * @throws Exception If failed. + */ + @Setup + public static void setup() throws Exception { + ignite1 = Ignition.start(config("node1")); + ignite2 = Ignition.start(config("node2")); + + cache1 = ignite1.cache(null); + + IgniteDataStreamer<Integer, IntValue> dataLdr = ignite1.dataStreamer(cache1.getName()); + + for (int i = 0; i < CNT; i++) + dataLdr.addData(i, new IntValue(i)); + + dataLdr.close(); + + System.out.println("Cache populated."); + } + + /** + * Tear down routine. + * + * @throws Exception If failed. + */ + @TearDown + public static void tearDown() throws Exception { + Ignition.stopAll(true); + } + + /** + * Create configuration. + * + * @param gridName Grid name. + * @return Configuration. + */ + private static IgniteConfiguration config(String gridName) { + IgniteConfiguration cfg = new IgniteConfiguration(); + + cfg.setGridName(gridName); + + cfg.setLocalHost("127.0.0.1"); + + TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + discoSpi.setIpFinder(IP_FINDER); + cfg.setDiscoverySpi(discoSpi); + + CacheConfiguration cacheCfg = new CacheConfiguration(); + + cacheCfg.setName(null); + cacheCfg.setCacheMode(CacheMode.PARTITIONED); + cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); + cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC); + cacheCfg.setBackups(1); + + cfg.setCacheConfiguration(cacheCfg); + + return cfg; + } + + /** + * Test PUT operation. + * + * @throws Exception If failed. + */ + @Benchmark + @Threads(4) + public void testPut() throws Exception { + int key = ThreadLocalRandom.current().nextInt(CNT); + + cache1.put(key, new IntValue(key)); + } + + /** + * Runner. + * + * @param args Arguments. + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + // Use the following additional options to record JFR dump: + // "-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder", "-XX:StartFlightRecording=delay=20s,duration=60s,filename=ignite-put_bench.jfr" + + String[] jvmArgs = new String[] { "-Xms4g", "-Xmx4g" }; + + Options opts = new OptionsBuilder().include(PutBenchmark.class.getSimpleName()).jvmArgs(jvmArgs).build(); + + new Runner(opts).run(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/bfae8665/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/model/IntValue.java ---------------------------------------------------------------------- diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/model/IntValue.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/model/IntValue.java new file mode 100644 index 0000000..0a97e36 --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/model/IntValue.java @@ -0,0 +1,91 @@ +/* + * 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.ignite.internal.benchmarks.model; + +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; +import org.apache.ignite.binary.Binarylizable; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +/** + * Simple wrapped int value. + */ +public class IntValue implements Externalizable, Binarylizable { + /** Value. */ + private int val; + + /** + * Default constructor. + */ + public IntValue() { + // No-op. + } + + /** + * Constructor. + * + * @param val Value. + */ + public IntValue(int val) { + this.val = val; + } + + /** + * @param val Value. + */ + public void value(int val) { + this.val = val; + } + + /** + * @return Value. + */ + public int value() { + return val; + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + val = in.readInt(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(val); + } + + /** {@inheritDoc} */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeInt("id", val); + } + + /** {@inheritDoc} */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + val = reader.readInt("id"); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Value [id=" + val + ']'; + } +} \ No newline at end of file
