Created
March 4, 2014 21:56
-
-
Save gurbuzali/9356616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final String mapName = "map"; | |
| final int count = 200000; | |
| boolean nearCache = false; | |
| int threadCount = 1; | |
| final ClientConfig clientConfig = new ClientConfig(); | |
| clientConfig.addAddress("127.0.0.1:5701"); | |
| if (nearCache) { | |
| final NearCacheConfig nearCacheConfig = new NearCacheConfig(); | |
| nearCacheConfig.setName(mapName); | |
| clientConfig.addNearCacheConfig(mapName, nearCacheConfig); | |
| } | |
| final HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); | |
| final IMap<Integer, Integer> map = client.getMap(mapName); | |
| final CountDownLatch latch = new CountDownLatch(threadCount); | |
| final AtomicLong put = new AtomicLong(); | |
| final AtomicLong get = new AtomicLong(); | |
| final AtomicLong evict = new AtomicLong(); | |
| for (int i=0; i<threadCount; i++) { | |
| final int id = i +1; | |
| new Thread(){ | |
| @Override | |
| public void run() { | |
| System.err.println("begin "); | |
| long begin = System.currentTimeMillis(); | |
| for (int i=0; i<count; i++) { | |
| map.put(i, i); | |
| } | |
| long elapsed = System.currentTimeMillis() - begin; | |
| put.addAndGet(elapsed); | |
| System.err.println("put " + elapsed); | |
| begin = System.currentTimeMillis(); | |
| for (int i=0; i<count; i++) { | |
| map.get(i); | |
| } | |
| elapsed = System.currentTimeMillis() - begin; | |
| get.addAndGet(elapsed); | |
| System.err.println("get " + elapsed); | |
| begin = System.currentTimeMillis(); | |
| for (int i=0; i<count; i++) { | |
| map.remove(i); | |
| } | |
| elapsed = System.currentTimeMillis() - begin; | |
| evict.addAndGet(elapsed); | |
| System.err.println("evict " + elapsed); | |
| latch.countDown(); | |
| } | |
| }.start(); | |
| } | |
| latch.await(); | |
| long averagePut = put.get() / threadCount; | |
| long averageGet = get.get() / threadCount; | |
| long averageEvict = evict.get() / threadCount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment