Improved cache.get benchmarks.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/07752ec8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/07752ec8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/07752ec8 Branch: refs/heads/ignite-1.9 Commit: 07752ec85dc3bf18297b728f9a31185d44ad3687 Parents: b6005b0 Author: sboikov <[email protected]> Authored: Wed Jan 11 13:51:23 2017 +0300 Committer: sboikov <[email protected]> Committed: Wed Jan 11 14:20:21 2017 +0300 ---------------------------------------------------------------------- .../yardstick/cache/IgniteGetAllBenchmark.java | 42 ++++++++++++++++++++ .../yardstick/cache/IgniteGetBenchmark.java | 38 +++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/07752ec8/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java new file mode 100644 index 0000000..2f76b7c --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java @@ -0,0 +1,42 @@ +/* + * 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.yardstick.cache; + +import java.util.Map; +import java.util.Set; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + * Ignite benchmark that performs getAll operations. + */ +public class IgniteGetAllBenchmark extends IgniteGetBenchmark { + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + Set<Integer> keys = U.newHashSet(args.batch()); + + while (keys.size() < args.batch()) { + int key = nextRandom(args.range()); + + keys.add(key); + } + + cache.getAll(keys); + + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/07752ec8/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java index 8a86e2f..918f571 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java @@ -19,11 +19,47 @@ package org.apache.ignite.yardstick.cache; import java.util.Map; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.yardstick.cache.model.SampleValue; +import org.yardstickframework.BenchmarkConfiguration; + +import static org.yardstickframework.BenchmarkUtils.println; /** * Ignite benchmark that performs get operations. */ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { + /** */ + private static final String CACHE_NAME = "atomic"; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + if (args.preloadAmount() > args.range()) + throw new IllegalArgumentException("Preloading amount (\"-pa\", \"--preloadAmount\") " + + "must by less then the range (\"-r\", \"--range\")."); + + println(cfg, "Loading data..."); + + long start = System.nanoTime(); + + try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(CACHE_NAME)) { + for (int i = 0; i < args.preloadAmount(); i++) { + dataLdr.addData(i, new SampleValue(i)); + + if (i % 100000 == 0) { + if (Thread.currentThread().isInterrupted()) + break; + + println("Loaded entries: " + i); + } + } + } + + println(cfg, "Finished populating query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms."); + } + /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); @@ -35,6 +71,6 @@ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Ob /** {@inheritDoc} */ @Override protected IgniteCache<Integer, Object> cache() { - return ignite().cache("atomic"); + return ignite().cache(CACHE_NAME); } }
