3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $numbers = range(32, 127); $numbersLetters = array_map('chr', $numbers); for (;;) { $numbersLetters = array_merge($numbersLetters, $numbersLetters); if (count($numbersLetters) > 1000) { break; } } $numbers = range(1, count($numbersLetters)); printf("Sample size: %d elements in 2 arrays (%d total) \n", count($numbers), count($numbers) + count($numbersLetters)); // =============================------------=============================== printf("Benchmarking speed in foreach + in_array() scenario... (this might take a while) "); shuffle($numbers); shuffle($numbersLetters); $t1 = microtime(true); foreach ($numbers as $number) { if (in_array($number, $numbersLetters)) {} } $t2 = microtime(true); printf("DONE!\n"); printf("Time elapsed: %.5f \n", $t2 - $t1); // =============================------------=============================== printf("Benchmarking speed with array_intersect..."); shuffle($numbers); shuffle($numbersLetters); $t1 = microtime(true); array_intersect($numbers, $numbersLetters); $t2 = microtime(true); printf("DONE!\n"); printf("Time elapsed: %.5f \n", $t2 - $t1);
Output for 7.2.6
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.03764 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00126
Output for 7.2.0
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.04665 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00218
Output for 7.1.10
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.03296 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00123
Output for 7.1.7
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.03834 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00120
Output for 7.1.6
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.10949 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00176
Output for 7.1.5
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05383 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00205
Output for 7.1.4
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05573 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00176
Output for 7.1.3
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05727 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00197
Output for 7.1.2
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05383 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00204
Output for 7.1.1
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08127 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00264
Output for 7.1.0
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05641 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00208
Output for 7.0.20
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07595 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00312
Output for 7.0.19
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05316 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00173
Output for 7.0.18
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05348 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00202
Output for 7.0.17
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05402 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00200
Output for 7.0.16
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.06834 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00162
Output for 7.0.15
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05479 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00170
Output for 7.0.14
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05208 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00210
Output for 7.0.13
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05721 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00171
Output for 7.0.12
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.06168 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00164
Output for 7.0.11
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05578 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00258
Output for 7.0.10
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05510 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00195
Output for 7.0.9
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05154 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00162
Output for 7.0.8
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05551 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00162
Output for 7.0.7
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.06634 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00236
Output for 7.0.6
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05207 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00209
Output for 7.0.5
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05573 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00178
Output for 7.0.4
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05435 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00160
Output for 7.0.3
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05545 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00177
Output for 7.0.2
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05408 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00195
Output for 7.0.1
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07147 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00371
Output for 7.0.0
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.05263 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00223
Output for hhvm-3.15.4
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.02791 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00015
Output for 5.6.30
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08253 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00548
Output for 5.6.29
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08140 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00576
Output for 5.6.28
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08860 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00474
Output for 5.6.27
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.10582 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00466
Output for 5.6.26
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.09544 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00505
Output for 5.6.25
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08345 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00906
Output for 5.6.24
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07833 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00542
Output for 5.6.23
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08678 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00519
Output for 5.6.22
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08139 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00553
Output for 5.6.21
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07664 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00652
Output for 5.6.20
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08343 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00410
Output for 5.6.19
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08406 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00447
Output for 5.6.18
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08985 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00519
Output for 5.6.17
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08253 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00513
Output for 5.6.16
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.09533 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00573
Output for 5.6.15
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08643 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00537
Output for 5.6.14
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07978 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00486
Output for 5.6.13
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07655 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00491
Output for 5.6.12
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07667 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00395
Output for 5.6.11
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07487 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00444
Output for 5.6.10
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07437 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00396
Output for 5.6.9
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08340 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00549
Output for 5.6.8
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07984 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00492
Output for 5.6.7
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08047 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00443
Output for 5.6.6
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07869 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00588
Output for 5.6.5
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.09734 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00444
Output for 5.6.4
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.10890 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00511
Output for 5.6.3
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.09079 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00573
Output for 5.6.2
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.07817 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00481
Output for 5.6.1
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08660 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00492
Output for 5.6.0
Sample size: 1536 elements in 2 arrays (3072 total) Benchmarking speed in foreach + in_array() scenario... (this might take a while) DONE! Time elapsed: 0.08509 Benchmarking speed with array_intersect...DONE! Time elapsed: 0.00447