Files
Chronicle-Map/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java
T
Peter Lawrey 87449b7d99 Replace "throws Exception" with the specific Exception(s) thrown.
Conflicts:
	src/main/java/net/openhft/chronicle/map/EngineReplicationLangBytes.java
	src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java
	src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java
	src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java
	src/test/java/net/openhft/chronicle/map/IntIntMultiMapTest.java
2015-07-25 23:25:54 +03:00

57 lines
2.0 KiB
Java

/*
* Copyright (C) 2015 higherfrequencytrading.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.openhft.chronicle.map;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
/**
* @author Anshul Shelley
*/
public class CHMTestIterator1 {
public static void main(String[] args) {
AtomicLong alValue = new AtomicLong();
AtomicLong alKey = new AtomicLong();
int runs = 3000000;
ChronicleMapBuilder<String, Long> builder = ChronicleMapBuilder.of(String.class, Long.class)
.entries(runs);
try (ChronicleMap<String, Long> chm = builder.create()) {
/*chm.put("k1", alValue.incrementAndGet());
chm.put("k2", alValue.incrementAndGet());
chm.put("k3", alValue.incrementAndGet());
chm.put("k4", alValue.incrementAndGet());
chm.put("k5", alValue.incrementAndGet());*/
//chm.keySet();
for (int i = 0; i < runs; i++) {
chm.put("k" + alKey.incrementAndGet(), alValue.incrementAndGet());
}
long start = System.nanoTime();
for (Map.Entry<String, Long> entry : chm.entrySet()) {
entry.getKey();
entry.getValue();
}
long time = System.nanoTime() - start;
System.out.println("Average iteration time was " + time / runs / 1e3 + "us, for " + runs / 1e6 + "m entries");
}
}
}