>you're also measuring the startup cost of PHP itself.

yup correct

>A simple microtime(true) benchmark loop as used with my test script should be 
>fine for ballpark estimates

agreed

>dwarfing the measurement overhead.

wouldn't count out random cpu context switch/background noise
completely, see my hyperfine benchmark for cost 13:
>  Range (min … max):   717.3 ms … 754.5 ms    10 runs
- over 10 runs, the fastest was 717ms and the slowest was 754ms, so
background noise made at least 37ms difference there.. but yeah
anyway, here's from your script:

hanshenrik@jonathan-dayton:~$ time php bench.php
Cost 8: 2.022854 total (0.020229 per hash)
Cost 9: 4.176210 total (0.041762 per hash)
Cost 10: 8.121596 total (0.081216 per hash)
Cost 11: 16.919405 total (0.169194 per hash)
Cost 12: 33.059071 total (0.330591 per hash)
Cost 13: 66.761731 total (0.667617 per hash)
Cost 14: 140.695820 total (1.406958 per hash)

real    4m31.854s
user    4m13.115s
sys     0m2.168s
hanshenrik@jonathan-dayton:~$ cat /proc/cpuinfo | head
(...)
model name      : AMD Opteron(tm) Processor 4122

On Tue, 12 Sept 2023 at 18:01, Tim Düsterhus <t...@bastelstu.be> wrote:
>
> Hi
>
> On 9/12/23 17:56, Hans Henrik Bergan wrote:
> >> web hosters *love* their ancient hardware
> >
> > No kidding. dreamhost.com host over 1.5 million websites, presumably most
> > are on their "Shared Unlimited" package, which runs on
> > AMD Opteron 4122, a high-end server CPU from 2010.
> > Some benchmarks there:
>
> It appears your benchmarks are broken, because you're also measuring the
> startup cost of PHP itself. You should see an approximate doubling in
> time taken for each increase of the cost, but you have 122ms for 9 and
> 166ms for 10.
>
> A simple microtime(true) benchmark loop as used with my test script
> should be fine for ballpark estimates, as password_hash() is pretty
> heavy, dwarfing the measurement overhead.
>
> Best regards
> Tim Düsterhus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to