Created
July 18, 2012 13:39
-
-
Save jlandure/3136269 to your computer and use it in GitHub Desktop.
TestPerfHashmap.java
This file contains 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
import java.util.HashMap; | |
import javax.cache.CacheException; | |
import org.perf4j.StopWatch; | |
public class TestPerfHashmap { | |
public static final String KEY = "KEY"; | |
public static final String VALUE = "VALUE"; | |
public static void main(String[] args) throws CacheException { | |
StopWatch stopWatch = new StopWatch(); | |
HashMap<String, String> maps = new HashMap<>(); | |
for (int i = 0; i < 1_000_000; i++) { | |
String key = KEY + i; | |
String value = VALUE + i; | |
System.out.println("get Object in memory :" + maps.get(key)); | |
// set a new object | |
System.out.println("set Object in memory :" + maps.put(key, value)); | |
System.out.println("Get Object after set :" + maps.get(key)); | |
} | |
stopWatch.stop(); | |
System.out.println("OldFashion Elapsed Time: " + stopWatch.getElapsedTime()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment