3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo "<pre>"; $results = array( "m1" => 0, "m2" => 0 ); $repeat = 1000; for($i = 0; $i < $repeat; $i ++) { foreach($results as $k => $no) { $results[$k] += $k($repeat); } if ($i == 0) { printf("First Run\n%s\n\n", json_encode($results, 128)); } } printf("100 Runs\n%s\n", json_encode($results, 128)); function m1($x) { $data = array(); $collision = 0; for($i = 0; $i < $x; $i ++) { $n = (rand() ^ (rand() / getrandmax())) % 256; isset($data[$n]) and $collision ++; $data[$n] = true; } return $collision; } function m2($x) { $data = array(); $collision = 0; for($i = 0; $i < $x; $i ++) { $n = (rand() ^ rand()) % 256; isset($data[$n]) and $collision ++; $data[$n] = true; } return $collision; } ?>
Output for 7.1.0
<pre>First Run { "m1": 751, "m2": 752 } 100 Runs { "m1": 749109, "m2": 749029 }
Output for 7.0.14
<pre>First Run { "m1": 750, "m2": 750 } 100 Runs { "m1": 749161, "m2": 749202 }
Output for 7.0.12
<pre>First Run { "m1": 750, "m2": 748 } 100 Runs { "m1": 749140, "m2": 749103 }
Output for 7.0.9
<pre>First Run { "m1": 750, "m2": 751 } 100 Runs { "m1": 748964, "m2": 749205 }
Output for 7.0.8
<pre>First Run { "m1": 752, "m2": 751 } 100 Runs { "m1": 749102, "m2": 749168 }
Output for 7.0.7
<pre>First Run { "m1": 749, "m2": 748 } 100 Runs { "m1": 749176, "m2": 749026 }
Output for 7.0.6
<pre>First Run { "m1": 749, "m2": 747 } 100 Runs { "m1": 749216, "m2": 749145 }
Output for 7.0.5
<pre>First Run { "m1": 750, "m2": 748 } 100 Runs { "m1": 749185, "m2": 749092 }
Output for 7.0.4
<pre>First Run { "m1": 749, "m2": 749 } 100 Runs { "m1": 749032, "m2": 749120 }
Output for 7.0.3
<pre>First Run { "m1": 752, "m2": 747 } 100 Runs { "m1": 749207, "m2": 749059 }
Output for 7.0.2
<pre>First Run { "m1": 749, "m2": 748 } 100 Runs { "m1": 749037, "m2": 749022 }
Output for 7.0.1
<pre>First Run { "m1": 748, "m2": 746 } 100 Runs { "m1": 749098, "m2": 749056 }
Output for 7.0.0
<pre>First Run { "m1": 749, "m2": 746 } 100 Runs { "m1": 749035, "m2": 749135 }
Output for hhvm-3.12.0
<pre>First Run { "m1": 749, "m2": 744 } 100 Runs { "m1": 749193, "m2": 749074 }
Output for hhvm-3.10.0
<pre>First Run { "m1": 748, "m2": 750 } 100 Runs { "m1": 749113, "m2": 749210 }
Output for 5.6.28
<pre>First Run { "m1": 753, "m2": 749 } 100 Runs { "m1": 749092, "m2": 749085 }
Output for 5.6.24
<pre>First Run { "m1": 750, "m2": 750 } 100 Runs { "m1": 749069, "m2": 749012 }
Output for 5.6.23
<pre>First Run { "m1": 749, "m2": 757 } 100 Runs { "m1": 749173, "m2": 749152 }
Output for 5.6.22
<pre>First Run { "m1": 747, "m2": 751 } 100 Runs { "m1": 749105, "m2": 749075 }
Output for 5.6.21
<pre>First Run { "m1": 751, "m2": 748 } 100 Runs { "m1": 749142, "m2": 749186 }
Output for 5.6.20
<pre>First Run { "m1": 750, "m2": 749 } 100 Runs { "m1": 749164, "m2": 749112 }
Output for 5.6.19
<pre>First Run { "m1": 749, "m2": 750 } 100 Runs { "m1": 749072, "m2": 749084 }
Output for 5.6.18
<pre>First Run { "m1": 751, "m2": 749 } 100 Runs { "m1": 749015, "m2": 749151 }
Output for 5.6.17
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749140, "m2": 749194 }
Output for 5.6.16
<pre>First Run { "m1": 748, "m2": 748 } 100 Runs { "m1": 749110, "m2": 749016 }
Output for 5.6.15
<pre>First Run { "m1": 749, "m2": 749 } 100 Runs { "m1": 749111, "m2": 748955 }
Output for 5.6.14
<pre>First Run { "m1": 749, "m2": 745 } 100 Runs { "m1": 749204, "m2": 749139 }
Output for 5.6.13
<pre>First Run { "m1": 749, "m2": 747 } 100 Runs { "m1": 749018, "m2": 749116 }
Output for 5.6.12
<pre>First Run { "m1": 746, "m2": 747 } 100 Runs { "m1": 749024, "m2": 749078 }
Output for 5.6.11
<pre>First Run { "m1": 749, "m2": 751 } 100 Runs { "m1": 749144, "m2": 749257 }
Output for 5.6.10
<pre>First Run { "m1": 749, "m2": 746 } 100 Runs { "m1": 749113, "m2": 749049 }
Output for 5.6.9
<pre>First Run { "m1": 752, "m2": 748 } 100 Runs { "m1": 749065, "m2": 749016 }
Output for 5.6.8
<pre>First Run { "m1": 750, "m2": 746 } 100 Runs { "m1": 749141, "m2": 749076 }
Output for 5.6.7
<pre>First Run { "m1": 747, "m2": 745 } 100 Runs { "m1": 749164, "m2": 749112 }
Output for 5.6.6
<pre>First Run { "m1": 751, "m2": 749 } 100 Runs { "m1": 749203, "m2": 749222 }
Output for 5.6.5
<pre>First Run { "m1": 751, "m2": 752 } 100 Runs { "m1": 749059, "m2": 749091 }
Output for 5.6.4
<pre>First Run { "m1": 748, "m2": 750 } 100 Runs { "m1": 749108, "m2": 749246 }
Output for 5.6.3
<pre>First Run { "m1": 750, "m2": 748 } 100 Runs { "m1": 749085, "m2": 749077 }
Output for 5.6.2
<pre>First Run { "m1": 745, "m2": 749 } 100 Runs { "m1": 749045, "m2": 749074 }
Output for 5.6.1
<pre>First Run { "m1": 751, "m2": 756 } 100 Runs { "m1": 749100, "m2": 749222 }
Output for 5.6.0
<pre>First Run { "m1": 750, "m2": 749 } 100 Runs { "m1": 749206, "m2": 749136 }
Output for 5.5.38
<pre>First Run { "m1": 748, "m2": 755 } 100 Runs { "m1": 749077, "m2": 749082 }
Output for 5.5.37
<pre>First Run { "m1": 748, "m2": 744 } 100 Runs { "m1": 749255, "m2": 749068 }
Output for 5.5.36
<pre>First Run { "m1": 750, "m2": 747 } 100 Runs { "m1": 749091, "m2": 749008 }
Output for 5.5.35
<pre>First Run { "m1": 749, "m2": 750 } 100 Runs { "m1": 749108, "m2": 748994 }
Output for 5.5.34
<pre>First Run { "m1": 747, "m2": 752 } 100 Runs { "m1": 749158, "m2": 749058 }
Output for 5.5.33
<pre>First Run { "m1": 751, "m2": 749 } 100 Runs { "m1": 749049, "m2": 749063 }
Output for 5.5.32
<pre>First Run { "m1": 749, "m2": 750 } 100 Runs { "m1": 749262, "m2": 749036 }
Output for 5.5.31
<pre>First Run { "m1": 750, "m2": 746 } 100 Runs { "m1": 749139, "m2": 749097 }
Output for 5.5.30
<pre>First Run { "m1": 755, "m2": 748 } 100 Runs { "m1": 749077, "m2": 749041 }
Output for 5.5.29
<pre>First Run { "m1": 751, "m2": 749 } 100 Runs { "m1": 749098, "m2": 749080 }
Output for 5.5.28
<pre>First Run { "m1": 752, "m2": 751 } 100 Runs { "m1": 749174, "m2": 748965 }
Output for 5.5.27
<pre>First Run { "m1": 750, "m2": 752 } 100 Runs { "m1": 749154, "m2": 749228 }
Output for 5.5.26
<pre>First Run { "m1": 747, "m2": 748 } 100 Runs { "m1": 749060, "m2": 749052 }
Output for 5.5.25
<pre>First Run { "m1": 750, "m2": 749 } 100 Runs { "m1": 749122, "m2": 749157 }
Output for 5.5.24
<pre>First Run { "m1": 751, "m2": 751 } 100 Runs { "m1": 749187, "m2": 749170 }
Output for 5.5.23
<pre>First Run { "m1": 748, "m2": 746 } 100 Runs { "m1": 749107, "m2": 749053 }
Output for 5.5.22
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749157, "m2": 749062 }
Output for 5.5.21
<pre>First Run { "m1": 746, "m2": 750 } 100 Runs { "m1": 749076, "m2": 749099 }
Output for 5.5.20
<pre>First Run { "m1": 752, "m2": 747 } 100 Runs { "m1": 748900, "m2": 749144 }
Output for 5.5.19
<pre>First Run { "m1": 749, "m2": 749 } 100 Runs { "m1": 749038, "m2": 749188 }
Output for 5.5.18
<pre>First Run { "m1": 748, "m2": 754 } 100 Runs { "m1": 749284, "m2": 749192 }
Output for 5.5.16
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749190, "m2": 749061 }
Output for 5.5.15
<pre>First Run { "m1": 749, "m2": 745 } 100 Runs { "m1": 749186, "m2": 749056 }
Output for 5.5.14
<pre>First Run { "m1": 754, "m2": 748 } 100 Runs { "m1": 749122, "m2": 749030 }
Output for 5.5.13
<pre>First Run { "m1": 749, "m2": 749 } 100 Runs { "m1": 749025, "m2": 749012 }
Output for 5.5.12
<pre>First Run { "m1": 750, "m2": 750 } 100 Runs { "m1": 749139, "m2": 749094 }
Output for 5.5.11
<pre>First Run { "m1": 751, "m2": 747 } 100 Runs { "m1": 749079, "m2": 749174 }
Output for 5.5.10
<pre>First Run { "m1": 749, "m2": 748 } 100 Runs { "m1": 749179, "m2": 749216 }
Output for 5.5.9
<pre>First Run { "m1": 748, "m2": 750 } 100 Runs { "m1": 749275, "m2": 749161 }
Output for 5.5.8
<pre>First Run { "m1": 750, "m2": 748 } 100 Runs { "m1": 749112, "m2": 749113 }
Output for 5.5.7
<pre>First Run { "m1": 749, "m2": 747 } 100 Runs { "m1": 749100, "m2": 749148 }
Output for 5.5.6
<pre>First Run { "m1": 748, "m2": 751 } 100 Runs { "m1": 749040, "m2": 749027 }
Output for 5.5.5
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749103, "m2": 749049 }
Output for 5.5.4
<pre>First Run { "m1": 751, "m2": 745 } 100 Runs { "m1": 749059, "m2": 748947 }
Output for 5.5.3
<pre>First Run { "m1": 750, "m2": 746 } 100 Runs { "m1": 749070, "m2": 749153 }
Output for 5.5.2
<pre>First Run { "m1": 751, "m2": 747 } 100 Runs { "m1": 748961, "m2": 748995 }
Output for 5.5.1
<pre>First Run { "m1": 748, "m2": 753 } 100 Runs { "m1": 749263, "m2": 749031 }
Output for 5.5.0
<pre>First Run { "m1": 749, "m2": 752 } 100 Runs { "m1": 749174, "m2": 749121 }
Output for 5.4.45
<pre>First Run { "m1": 748, "m2": 752 } 100 Runs { "m1": 749101, "m2": 749113 }
Output for 5.4.44
<pre>First Run { "m1": 750, "m2": 750 } 100 Runs { "m1": 749267, "m2": 749233 }
Output for 5.4.43
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749156, "m2": 749109 }
Output for 5.4.42
<pre>First Run { "m1": 751, "m2": 748 } 100 Runs { "m1": 749215, "m2": 749075 }
Output for 5.4.41
<pre>First Run { "m1": 747, "m2": 745 } 100 Runs { "m1": 749078, "m2": 749067 }
Output for 5.4.40
<pre>First Run { "m1": 745, "m2": 749 } 100 Runs { "m1": 749021, "m2": 749230 }
Output for 5.4.39
<pre>First Run { "m1": 750, "m2": 751 } 100 Runs { "m1": 749046, "m2": 749135 }
Output for 5.4.38
<pre>First Run { "m1": 746, "m2": 746 } 100 Runs { "m1": 749146, "m2": 749139 }
Output for 5.4.37
<pre>First Run { "m1": 753, "m2": 750 } 100 Runs { "m1": 749173, "m2": 749128 }
Output for 5.4.36
<pre>First Run { "m1": 754, "m2": 747 } 100 Runs { "m1": 749052, "m2": 749138 }
Output for 5.4.35
<pre>First Run { "m1": 750, "m2": 750 } 100 Runs { "m1": 749027, "m2": 749112 }
Output for 5.4.34
<pre>First Run { "m1": 749, "m2": 747 } 100 Runs { "m1": 749003, "m2": 749174 }
Output for 5.4.32
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749157, "m2": 748949 }
Output for 5.4.31
<pre>First Run { "m1": 750, "m2": 748 } 100 Runs { "m1": 749141, "m2": 749140 }
Output for 5.4.30
<pre>First Run { "m1": 746, "m2": 748 } 100 Runs { "m1": 749104, "m2": 749194 }
Output for 5.4.29
<pre>First Run { "m1": 750, "m2": 749 } 100 Runs { "m1": 749170, "m2": 749045 }
Output for 5.4.28
<pre>First Run { "m1": 750, "m2": 750 } 100 Runs { "m1": 749198, "m2": 749100 }
Output for 5.4.27
<pre>First Run { "m1": 750, "m2": 747 } 100 Runs { "m1": 749073, "m2": 749097 }
Output for 5.4.26
<pre>First Run { "m1": 755, "m2": 751 } 100 Runs { "m1": 749061, "m2": 749037 }
Output for 5.4.25
<pre>First Run { "m1": 749, "m2": 746 } 100 Runs { "m1": 749184, "m2": 749147 }
Output for 5.4.24
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749037, "m2": 749074 }
Output for 5.4.23
<pre>First Run { "m1": 748, "m2": 754 } 100 Runs { "m1": 749065, "m2": 749105 }
Output for 5.4.22
<pre>First Run { "m1": 751, "m2": 749 } 100 Runs { "m1": 749202, "m2": 749088 }
Output for 5.4.21
<pre>First Run { "m1": 749, "m2": 748 } 100 Runs { "m1": 749060, "m2": 749096 }
Output for 5.4.20
<pre>First Run { "m1": 748, "m2": 747 } 100 Runs { "m1": 749190, "m2": 749039 }
Output for 5.4.19
<pre>First Run { "m1": 747, "m2": 747 } 100 Runs { "m1": 749148, "m2": 749107 }
Output for 5.4.18
<pre>First Run { "m1": 751, "m2": 747 } 100 Runs { "m1": 749102, "m2": 749076 }
Output for 5.4.17
<pre>First Run { "m1": 749, "m2": 748 } 100 Runs { "m1": 749172, "m2": 749149 }
Output for 5.4.16
<pre>First Run { "m1": 748, "m2": 750 } 100 Runs { "m1": 749086, "m2": 749077 }
Output for 5.4.15
<pre>First Run { "m1": 749, "m2": 749 } 100 Runs { "m1": 749175, "m2": 749123 }
Output for 5.4.14
<pre>First Run { "m1": 750, "m2": 747 } 100 Runs { "m1": 749115, "m2": 749169 }
Output for 5.4.13
<pre>First Run { "m1": 746, "m2": 748 } 100 Runs { "m1": 749074, "m2": 749222 }
Output for 5.4.12
<pre>First Run { "m1": 751, "m2": 750 } 100 Runs { "m1": 749210, "m2": 748902 }
Output for 5.4.11
<pre>First Run { "m1": 745, "m2": 750 } 100 Runs { "m1": 749158, "m2": 748970 }
Output for 5.4.10
<pre>First Run { "m1": 746, "m2": 749 } 100 Runs { "m1": 749212, "m2": 749085 }
Output for 5.4.9
<pre>First Run { "m1": 748, "m2": 749 } 100 Runs { "m1": 749159, "m2": 749080 }
Output for 5.4.8
<pre>First Run { "m1": 750, "m2": 752 } 100 Runs { "m1": 749149, "m2": 748984 }
Output for 5.4.7
<pre>First Run { "m1": 749, "m2": 752 } 100 Runs { "m1": 748988, "m2": 749149 }
Output for 5.4.6
<pre>First Run { "m1": 751, "m2": 745 } 100 Runs { "m1": 749135, "m2": 749171 }
Output for 5.4.5
<pre>First Run { "m1": 745, "m2": 750 } 100 Runs { "m1": 749168, "m2": 749173 }
Output for 5.4.4
<pre>First Run { "m1": 750, "m2": 752 } 100 Runs { "m1": 749147, "m2": 749206 }
Output for 5.4.3
<pre>First Run { "m1": 748, "m2": 746 } 100 Runs { "m1": 749108, "m2": 749221 }
Output for 5.4.2
<pre>First Run { "m1": 747, "m2": 750 } 100 Runs { "m1": 748979, "m2": 749060 }
Output for 5.4.1
<pre>First Run { "m1": 754, "m2": 750 } 100 Runs { "m1": 749145, "m2": 749087 }
Output for 5.4.0
<pre>First Run { "m1": 748, "m2": 746 } 100 Runs { "m1": 749154, "m2": 749186 }
Output for 5.3.29
<pre>First Run {"m1":750,"m2":750} 100 Runs {"m1":749259,"m2":749173}
Output for 5.3.28
<pre>First Run {"m1":749,"m2":753} 100 Runs {"m1":749036,"m2":749070}
Output for 5.3.27
<pre>First Run {"m1":748,"m2":751} 100 Runs {"m1":749029,"m2":749047}
Output for 5.3.26
<pre>First Run {"m1":749,"m2":753} 100 Runs {"m1":749115,"m2":749001}
Output for 5.3.25
<pre>First Run {"m1":754,"m2":749} 100 Runs {"m1":749147,"m2":749097}
Output for 5.3.24
<pre>First Run {"m1":753,"m2":751} 100 Runs {"m1":749196,"m2":749162}
Output for 5.3.23
<pre>First Run {"m1":749,"m2":748} 100 Runs {"m1":749095,"m2":749167}
Output for 5.3.22
<pre>First Run {"m1":750,"m2":745} 100 Runs {"m1":749074,"m2":749054}
Output for 5.3.21
<pre>First Run {"m1":747,"m2":749} 100 Runs {"m1":749055,"m2":749069}
Output for 5.3.20
<pre>First Run {"m1":749,"m2":748} 100 Runs {"m1":749254,"m2":749124}
Output for 5.3.19
<pre>First Run {"m1":748,"m2":747} 100 Runs {"m1":749087,"m2":749080}
Output for 5.3.18
<pre>First Run {"m1":748,"m2":749} 100 Runs {"m1":748983,"m2":749106}
Output for 5.3.17
<pre>First Run {"m1":749,"m2":758} 100 Runs {"m1":749168,"m2":749142}
Output for 5.3.16
<pre>First Run {"m1":746,"m2":751} 100 Runs {"m1":749115,"m2":749167}
Output for 5.3.15
<pre>First Run {"m1":748,"m2":746} 100 Runs {"m1":749196,"m2":749100}
Output for 5.3.14
<pre>First Run {"m1":746,"m2":750} 100 Runs {"m1":749115,"m2":749063}
Output for 5.3.13
<pre>First Run {"m1":748,"m2":746} 100 Runs {"m1":749184,"m2":749119}
Output for 5.3.12
<pre>First Run {"m1":750,"m2":753} 100 Runs {"m1":749127,"m2":749069}
Output for 5.3.11
<pre>First Run {"m1":751,"m2":748} 100 Runs {"m1":749137,"m2":749102}
Output for 5.3.10
<pre>First Run {"m1":749,"m2":750} 100 Runs {"m1":749156,"m2":749129}
Output for 5.3.9
<pre>First Run {"m1":747,"m2":749} 100 Runs {"m1":749135,"m2":749193}
Output for 5.3.8
<pre>First Run {"m1":748,"m2":754} 100 Runs {"m1":749130,"m2":749135}
Output for 5.3.7
<pre>First Run {"m1":745,"m2":748} 100 Runs {"m1":749191,"m2":749168}
Output for 5.3.6
<pre>First Run {"m1":753,"m2":749} 100 Runs {"m1":749044,"m2":749114}
Output for 5.3.5
<pre>First Run {"m1":753,"m2":752} 100 Runs {"m1":749134,"m2":749041}
Output for 5.3.4
<pre>First Run {"m1":750,"m2":747} 100 Runs {"m1":749179,"m2":749180}
Output for 5.3.3
<pre>First Run {"m1":749,"m2":748} 100 Runs {"m1":749140,"m2":749160}
Output for 5.3.2
<pre>First Run {"m1":746,"m2":749} 100 Runs {"m1":749063,"m2":749052}
Output for 5.3.1
<pre>First Run {"m1":750,"m2":746} 100 Runs {"m1":749185,"m2":749104}
Output for 5.3.0
<pre>First Run {"m1":746,"m2":747} 100 Runs {"m1":749070,"m2":749149}
Output for 5.2.0 - 5.2.17
<pre> Warning: json_encode() expects exactly 1 parameter, 2 given in /in/7LUmK on line 13 First Run Warning: json_encode() expects exactly 1 parameter, 2 given in /in/7LUmK on line 17 100 Runs
Output for 5.0.0 - 5.1.6
<pre> Fatal error: Call to undefined function json_encode() in /in/7LUmK on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<pre> Fatal error: Call to undefined function: json_encode() in /in/7LUmK on line 13
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<pre> Fatal error: Call to undefined function: json_encode() in /in/7LUmK on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<pre> Fatal error: Call to undefined function: json_encode() in /in/7LUmK on line 13