View Single Post
Old 01-09-2008, 11:03 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

The code available in your other topic (lets call this 'old') generates a page, for me, in roughly 2.x seconds. The test script in your PHL package ('new') generates the page in around 6.x seconds. Since you're running the hashing algorithm three times in the new code, that seems perfectly fine to me. It doesn't seem that the actual times being recorded are different.

I did notice however that your calculations for the outputting of the throughput were a bit screwy (that, or my math is terrible!). The speed values are given as the time in microseconds ($hash->m_fSpeed). We are using a 1MB file, so it takes fSpeed / 1000 seconds to complete the single test. The throughput would be 1 / (fSpeed / 1000) MB/s. So if the test was done in 0.5 microseconds, then the throughput would be 1 / (0.5 / 1000) or 1 / 0.0005 or 2000 MB/s. For GB it's a simple matter of dividing that value by 1024 (to make, 1.95 GB/s).

After applying that logic to the outputting of the throughputs in both the old code and the new, the values displayed are similar across the two tests.

Just so you're clear the code used to output the speed in the new PHL test is:
PHP Code:
// Mine
// Mathematically identical to (1.0 / (speed / 1000)) / 1024
number_format((1000.0 $hash->m_fSpeed) / 10242);
// Yours
number_format((1.0 $hash->m_fSpeed) / 10242); 
You're probably not looking to make changes to your 'old' code but here's the change I made to that:
PHP Code:
// Mine
<?php echo number_format((1000 $info['time']) / 10242); ?>GB/Sec
// Yours
<?= number_format($info['time'], 8); ?>MB/Sec
As you can see, both old and new code calculate the display the speed in the same way now.

To cut a long story short, for me at least the new version using classes doesn't appear to run any slower than expected. Let us know if you still get this issue
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
RobertK (01-09-2008)