|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-10-03 07:57 UTC] nikic@php.net
[2015-10-03 11:58 UTC] anna1008 at t-online dot de
[2015-10-03 13:20 UTC] anna1008 at t-online dot de
-Summary: gmp much faster with old VC6-builds
+Summary: gmp on windows much faster with php 5.2
[2015-10-03 13:20 UTC] anna1008 at t-online dot de
[2015-10-16 10:37 UTC] ab@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 04:00:01 2025 UTC |
Description: ------------ I've experienced slow performance of the recent VC11 builds compared to the old VC6 builds when running gmp_*-functions on big integers. My test script factorizes the first 1,000 integers >= 2^16, 2^24 and 2^32 with trial division. All tests were executed in CLI and shared the same php.ini (default production-ini just with gmp extension). Test script: --------------- <?php for ($e = 16; $e <= 32; $e+=8) { # 16, 24, 32 $n = gmp_pow(2, $e); # n := 2^e $t0 = microtime(true); for ($i = 0; $i < 1000; $i++) { trialdiv($n); $n = gmp_add($n, 1); # n++ } $dt = microtime(true) - $t0; echo phpversion() . " e=$e dt=$dt sec\n"; } function trialdiv($n) { if (gmp_prob_prime($n) != 0) return; # n is probably or surely prime $p = gmp_init(2); # start with prime 2 for (;;) { if (gmp_cmp(gmp_mul($p, $p), $n) > 0) return; # p^2 > n, trial division complete while (gmp_cmp(gmp_mod($n, $p), 0) == 0) $n = gmp_divexact($n, $p); # while p divides n do n:= n/p $p = gmp_nextprime($p); # try next prime } } ?> Expected result: ---------------- I've expected marginal performance differences between the old VC6-builds and the recent VC11-builds. Actual result: -------------- my results with php-5.2.14-Win32-VC6-x86: 5.2.14 e=16 dt=0.046411037445068 sec 5.2.14 e=24 dt=0.27050685882568 sec 5.2.14 e=32 dt=2.0851769447327 sec my results with php-5.6.14-Win32-VC11-x86: 5.6.14 e=16 dt=0.046800136566162 sec 5.6.14 e=24 dt=0.51480078697205 sec 5.6.14 e=32 dt=8.533215045929 sec summary: At 2^16 the differences are marginal. At 2^24 the VC6-build is 1.9 times faster At 2^32 the VC6-build is 4.1 times faster.