PageRenderTime 29ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/hazelcast/src/test/java/com/hazelcast/core/MultiMapPerformance.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 101 lines | 74 code | 12 blank | 15 comment | 8 complexity | fdff4439142d6e38bc9cb568858f3d6a MD5 | raw file
  1/*
  2 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3 *
  4 * Licensed under the Apache License, Version 2.0 (the "License");
  5 * you may not use this file except in compliance with the License.
  6 * You may obtain a copy of the License at
  7 *
  8 * http://www.apache.org/licenses/LICENSE-2.0
  9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed under the License is distributed on an "AS IS" BASIS,
 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 * See the License for the specific language governing permissions and
 14 * limitations under the License.
 15 */
 16
 17package com.hazelcast.core;
 18
 19import org.junit.After;
 20import org.junit.Test;
 21import org.junit.runner.RunWith;
 22
 23import java.util.Collection;
 24
 25import static org.junit.Assert.assertEquals;
 26
 27@RunWith(com.hazelcast.util.RandomBlockJUnit4ClassRunner.class)
 28public class MultiMapPerformance extends PerformanceTest {
 29    private MultiMap<String, String> map = Hazelcast.getMultiMap("MultiMapPerformance");
 30
 31    @After
 32    public void clear() {
 33        t.stop();
 34        t.printResult();
 35        map.clear();
 36        assertEquals(0, map.size());
 37    }
 38
 39    @Test
 40    public void testMultiMapPutWithSameKeyAndValue() {
 41        String test = "testMultiMapPutWithSameKeyAndValue";
 42        t = new PerformanceTimer(test, ops);
 43        for (int i = 0; i < ops; ++i) {
 44            map.put("Hello", "World");
 45        }
 46    }
 47
 48    @Test
 49    public void testMultiMapPutWithSameKeyAndDifferentValue() {
 50        String test = "testMultiMapPutWithSameKeyAndDifferentValue";
 51        ops /= 100;
 52        t = new PerformanceTimer(test, ops);
 53        for (int i = 0; i < ops; ++i) {
 54            map.put("Hello", "World" + i);
 55        }
 56        ops *= 100;
 57    }
 58
 59    @Test
 60    public void testMultiMapPutWithDifferentKey() {
 61        String test = "testMultiMapPutWithDifferentKey";
 62        t = new PerformanceTimer(test, ops);
 63        for (int i = 0; i < ops; ++i) {
 64            map.put("Hello" + i, "World");
 65        }
 66    }
 67
 68    @Test
 69    public void testMultiMapValues() {
 70        String test = "testMultiMapValues";
 71        for (int i = 0; i < ops; ++i) {
 72            map.put("Hello" + i, "World");
 73        }
 74        t = new PerformanceTimer(test, ops);
 75        Collection<String> values = map.values();
 76    }
 77
 78    @Test
 79    public void testMultiMapGet() {
 80        String test = "testMultiMapGet";
 81        for (int i = 0; i < ops; ++i) {
 82            map.put("Hello" + i, "World");
 83        }
 84        t = new PerformanceTimer(test, ops);
 85        for (int i = 0; i < ops; ++i) {
 86            Collection<String> values = map.get("Hello" + i);
 87        }
 88    }
 89
 90    @Test
 91    public void testMultiMapValueCount() {
 92        String test = "testMultiMapGet";
 93        for (int i = 0; i < ops; ++i) {
 94            map.put("Hello" + i, "World");
 95        }
 96        t = new PerformanceTimer(test, ops);
 97        for (int i = 0; i < ops; ++i) {
 98            int count = map.valueCount("Hello" + i);
 99        }
100    }
101}