Created
August 20, 2013 23:29
-
-
Save baroquebobcat/6288669 to your computer and use it in GitHub Desktop.
HashMap creation w/ concurrency across different jvm versions
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
| import java.lang.Integer | |
| import java.util.HashMap | |
| import java.util.ArrayList | |
| import java.util.List | |
| import java.util.concurrent.LinkedBlockingQueue | |
| class HashMapMania | |
| def self.initialize:void | |
| @@hole = LinkedBlockingQueue.new | |
| end | |
| def self.main(args: String[]) : void | |
| thread_count = Integer.parseInt args[0] | |
| map_count = Integer.parseInt args[1] | |
| time_limit = System.currentTimeMillis + Integer.parseInt(args[2]) * 1000 | |
| while System.currentTimeMillis < time_limit | |
| start = System.nanoTime | |
| threads = [] | |
| i = 0 | |
| while i < thread_count | |
| i+=1 | |
| hole = @@hole # bindings grumble grumble | |
| t = Thread.new do | |
| map_list = ArrayList.new | |
| while map_list.size < map_count | |
| hash = HashMap.new | |
| hash.put "x", map_list.size | |
| map_list.add(hash) | |
| end | |
| LinkedBlockingQueue(hole).add map_list | |
| end | |
| threads.add t | |
| end | |
| threads.each {|t:Thread| t.start } | |
| threads.each {|t:Thread| t.join } | |
| time = (System.nanoTime - start) / 1000000 | |
| total_maps = 0 | |
| prev = nil | |
| while m = @@hole.poll | |
| ArrayList(m).each do |map| | |
| # always 1, but doing this so it isn't dead code removed | |
| total_maps += HashMap(map).size | |
| end | |
| end | |
| puts "#{total_maps} #{time}" | |
| System.gc | |
| end | |
| end | |
| end |
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
| $ bash run_tests.sh | |
| Parsing... | |
| hash_map_mania.mirah | |
| Inferring types... | |
| WARNING: Misaligned end at mirah.lang.ast.StringCodeSource@6b5c9416:5:1 | |
| NOTE: closes block at mirah.lang.ast.StringCodeSource@6b5c9416:1:1 | |
| WARNING: Misaligned end at mirah.lang.ast.StringCodeSource@4641439f:5:1 | |
| NOTE: closes block at mirah.lang.ast.StringCodeSource@4641439f:1:1 | |
| WARNING: Misaligned end at mirah.lang.ast.StringCodeSource@6487d5bd:5:1 | |
| NOTE: closes block at mirah.lang.ast.StringCodeSource@6487d5bd:1:1 | |
| Compiling... | |
| hash_map_mania.mirah | |
| Done! | |
| java version "1.6.0_51" | |
| Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509) | |
| Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode) | |
| 16000000 4748 | |
| 16000000 3226 | |
| 16000000 3199 | |
| 16000000 3256 | |
| 16000000 3301 | |
| 16000000 3277 | |
| 16000000 3312 | |
| 16000000 3283 | |
| 16000000 3381 | |
| 16000000 3284 | |
| java version "1.7.0_15" | |
| Java(TM) SE Runtime Environment (build 1.7.0_15-b03) | |
| Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode) | |
| 16000000 18265 | |
| 16000000 11149 | |
| 16000000 4311 | |
| 16000000 4370 | |
| 16000000 4135 | |
| 16000000 4085 | |
| 16000000 4043 | |
| 16000000 4084 | |
| 16000000 4052 | |
| java version "1.7.0_25" | |
| Java(TM) SE Runtime Environment (build 1.7.0_25-b15) | |
| Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) | |
| 16000000 20089 | |
| 16000000 10993 | |
| 16000000 3862 | |
| 16000000 3925 | |
| 16000000 3663 | |
| 16000000 3775 | |
| 16000000 3753 | |
| 16000000 3754 | |
| 16000000 3830 | |
| java version "1.7.0_40-ea" | |
| Java(TM) SE Runtime Environment (build 1.7.0_40-ea-b38) | |
| Java HotSpot(TM) 64-Bit Server VM (build 24.0-b55, mixed mode) | |
| 16000000 10656 | |
| 16000000 7541 | |
| 16000000 1722 | |
| 16000000 1871 | |
| 16000000 1955 | |
| 16000000 1942 | |
| 16000000 1854 | |
| 16000000 1916 | |
| 16000000 1929 | |
| 16000000 1887 | |
| 16000000 1872 | |
| 16000000 1879 | |
| 16000000 1902 | |
| 16000000 1897 | |
| 16000000 1908 | |
| 16000000 1852 | |
| 16000000 1881 | |
| 16000000 1880 | |
| 16000000 1846 | |
| 16000000 1874 | |
| java version "1.8.0-ea" | |
| Java(TM) SE Runtime Environment (build 1.8.0-ea-b103) | |
| Java HotSpot(TM) 64-Bit Server VM (build 25.0-b45, mixed mode) | |
| 16000000 13751 | |
| 16000000 1744 | |
| 16000000 1914 | |
| 16000000 1932 | |
| 16000000 1970 | |
| 16000000 1943 | |
| 16000000 1930 | |
| 16000000 2008 | |
| 16000000 1971 | |
| 16000000 2259 | |
| 16000000 2041 | |
| 16000000 1976 | |
| 16000000 1927 | |
| 16000000 2005 | |
| 16000000 1997 | |
| 16000000 1954 | |
| 16000000 1996 | |
| 16000000 2001 | |
| 16000000 1993 |
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
| source ~/.bash_profile | |
| set -e | |
| map_count=2000000 | |
| thread_count=8 | |
| timelimit=60 | |
| java_change_16 | |
| mirahc hash_map_mania.mirah | |
| java_change_16 | |
| java -version | |
| java -Xmx6g -cp . HashMapMania $thread_count $map_count $timelimit | |
| java_change_17_15 | |
| java -version | |
| java -Xmx6g -cp . HashMapMania $thread_count $map_count $timelimit | |
| java_change_17_25 | |
| java -version | |
| java -Xmx6g -cp . HashMapMania $thread_count $map_count $timelimit | |
| java_change_17_40 | |
| java -version | |
| java -Xmx6g -cp . HashMapMania $thread_count $map_count $timelimit | |
| java_change_18 | |
| java -version | |
| java -Xmx6g -cp . HashMapMania $thread_count $map_count $timelimit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment