ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [09/16] ignite git commit: Added put-get batch benchmarks.
Date Tue, 15 Dec 2015 11:44:06 GMT
Added put-get batch benchmarks.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0c550aaa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0c550aaa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0c550aaa

Branch: refs/heads/ignite-1.5.1
Commit: 0c550aaaff03d5bb7f2157037f0377e293e185b7
Parents: ad95ed5
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Tue Dec 15 11:51:15 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Tue Dec 15 11:51:39 2015 +0300

----------------------------------------------------------------------
 .../cache/IgnitePutGetBatchBenchmark.java       | 61 ++++++++++++++
 .../cache/IgnitePutGetTxBatchBenchmark.java     | 87 ++++++++++++++++++++
 2 files changed, 148 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0c550aaa/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java
new file mode 100644
index 0000000..26097c0
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java
@@ -0,0 +1,61 @@
+/*
+ * 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 java.util.TreeMap;
+import java.util.TreeSet;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+/**
+ * Ignite benchmark that performs batch put and get operations.
+ */
+public class IgnitePutGetBatchBenchmark extends IgniteCacheAbstractBenchmark<Integer,
Object> {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        Set<Integer> keys = new TreeSet<>();
+
+        while (keys.size() < args.batch())
+            keys.add(nextRandom(args.range()));
+
+        Map<Integer, Object> vals = cache.getAll(keys);
+
+        Map<Integer, SampleValue> updates = new TreeMap<>();
+
+        for (Map.Entry<Integer, Object> e : vals.entrySet()) {
+            if (e.getValue() != null) {
+                int key = nextRandom(args.range());
+
+                updates.put(key, new SampleValue(key));
+            }
+            else
+                updates.put(e.getKey(), new SampleValue(e.getKey()));
+        }
+
+        cache.putAll(updates);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c550aaa/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java
new file mode 100644
index 0000000..930f08a
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java
@@ -0,0 +1,87 @@
+/*
+ * 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 java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction;
+
+/**
+ * Ignite benchmark that performs transactional put and get operations.
+ */
+public class IgnitePutGetTxBatchBenchmark extends IgniteCacheAbstractBenchmark<Integer,
Object> {
+    /** */
+    private IgniteTransactions txs;
+
+    /** */
+    private Callable<Void> clo;
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        txs = ignite().transactions();
+
+        clo = new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                Set<Integer> keys = new TreeSet<>();
+
+                while (keys.size() < args.batch())
+                    keys.add(nextRandom(args.range()));
+
+                Map<Integer, Object> vals = cache.getAll(keys);
+
+                Map<Integer, SampleValue> updates = new TreeMap<>();
+
+                for (Map.Entry<Integer, Object> e : vals.entrySet()) {
+                    if (e.getValue() != null) {
+                        int key = nextRandom(args.range());
+
+                        updates.put(key, new SampleValue(key));
+                    }
+                    else
+                        updates.put(e.getKey(), new SampleValue(e.getKey()));
+                }
+
+                cache.putAll(updates);
+
+                return null;
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        doInTransaction(txs, args.txConcurrency(), args.txIsolation(), clo);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("tx");
+    }
+}


Mime
View raw message