All these tests were done on my machine, which is an Athlon XP 2200,
512mb ram, 200gb hdd. Running Windows XP (all patches installed), IIS5
(all patches installed), and a fresh install of PHP and Zend Accelerator.
I waited till CPU usage was 0%, then ran the test, 10 times to make sure
it was a fair test. The webserver was "localhost", so there
would be no bandwidth or throughput issues involved
String Compare
The test was string comparison, and to test PHP with 8 million (8,000,000)
calculations, and ASP.NET with 80 million, 800million and 1.6billion calculations
(80,000,000, 800,000,000, 1,600,000,000 for a more accurate result).
ASP.NET Code (Compiled)
Private
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim i As Long
Response.Write("Stopwatch at :" & DateTime.Now.Second
& "." & DateTime.Now.Millisecond & ", For
reason: Start of loop<BR>")
For i = 1 To 80000000
If "hello" Is "world" Then
End If
Next
Response.Write("Stopwatch at :" & DateTime.Now.Second
& "." & DateTime.Now.Millisecond & ", For
reason: End of loop<BR>")
End Sub |
PHP Code
<?php
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$number = 0;
$time_start = getmicrotime();
for ($i=0; $i < 8000000; $i++){
if ("hello" == "world") { }
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Did 8 Million
Additions in $time seconds";
?>
|
The PHP tests were done using the Zend Accelerator.
The results where:
| |
Start Time |
End time |
Time Taken |
| ASP.NET@ 80 Mil |
10.000 |
10.218 |
0.218 |
| ASP.NET@ 800 Mil |
56.546 |
58.796 |
2.250 |
| ASP.NET@ 1.6Billion |
44.890 |
49.671 |
4.781 |
| PHP @ 8 Million |
N/A |
4.561 |
|