|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-07-23 10:58 UTC] nikic@php.net
-Status: Open
+Status: Verified
[2020-07-23 10:58 UTC] nikic@php.net
[2020-07-23 11:49 UTC] carusogabriel@php.net
-PHP Version: 8.0.0alpha2
+PHP Version: 8.0.0alpha3
[2020-07-29 13:31 UTC] dmitry@php.net
-Status: Verified
+Status: Assigned
-Assigned To:
+Assigned To: dmitry
[2020-07-29 14:33 UTC] dmitry@php.net
[2020-07-29 14:33 UTC] dmitry@php.net
-Status: Assigned
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 09:00:02 2025 UTC |
Description: ------------ I have a very basic script for getting the ammount of PrimeNumbers by doing cascaded loops. It's mainly for testing execution times of differen programming languages. When enabling the JIT options, the final result of the script shows an incorrect result. Test was with Alpha3 of Php8, but could not choose that version in Dropdown yet. -------- skaeser@whiplash:~/code/php$ time php7.4 TestPrime.php Testing Primes until: 250000 Primect: 22044 real 0m56,470s user 0m56,456s sys 0m0,009s skaeser@whiplash:~/code/php$ time php8.0 TestPrime.php Testing Primes until: 250000 Primect: 22044 real 0m43,745s user 0m43,733s sys 0m0,008s skaeser@whiplash:~/code/php$ time php8.0 -d opcache.enable_cli=1 -d opcache.jit_buffer_size=50000000 -d opcache.jit=1235 TestPrime.php Testing Primes until: 250000 Primect: 124998 real 0m0,023s user 0m0,014s sys 0m0,009s Test script: --------------- <?php $max = 250000; $cnt = 0; echo "Testing Primes until: " . $max . "\n"; for ($i = 2; $i <= $max; $i++) { if (testPrime($i)) $cnt++; } echo "Primect: {$cnt}\n"; function testPrime(int $a): bool { if ($a < 2) { return false; } else if ($a == 2) { return true; } for ($j = 2; $j < $a; $j++) { if (($a % $j) == 0) { return false; } } return true; } Expected result: ---------------- Testing Primes until: 250000 Primect: 22044 Actual result: -------------- Only with JIT enabled: Testing Primes until: 250000 Primect: 124998