You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/01/11 10:51:28 UTC
ignite git commit: Improved cache.get benchmarks.
Repository: ignite
Updated Branches:
refs/heads/ignite-3477 9d38f6bba -> 2185adc24
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/2185adc2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2185adc2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2185adc2
Branch: refs/heads/ignite-3477
Commit: 2185adc240f91faa1fec23dc8846f23e15c8098f
Parents: 9d38f6b
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 11 13:51:23 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 11 13:51:23 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/2185adc2/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/2185adc2/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);
}
}