is @ on function damn slow?
Posted: Tue Apr 18, 2006 7:06 am
Hi,
I was told that @ operator slows down function call like 400%.
Is this any true?
I was told that @ operator slows down function call like 400%.
Is this any true?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
of course there was no error. I have display errors and E_ALL on reportingmalcolmboston wrote:probably because you are surpressing a potential error therefore carrying on processing code whereas without surpressing the error it would automatically quit?
guys you are definitely not with me hereOren wrote:When you use '@' no errors will be reported regardless to your error reporting level.
Code: Select all
<?php
// array for storing times
$data_array = array();
$final_array = array();
// some data for test functions
$test_array = array('1','2','3','4','5','6','a','b','c','d','e','f');
$j=1;
for($i=0;$i<1000000;$i++){
// start the timer
$time_start = microtime(1);
// a test function
array_reverse($test_array);
// stop the timer
$time_end = microtime(1);
// calculate total time
$total_time = $time_end-$time_start;
// store in an array
$data_array[] = $total_time;
// need to clear?
if($j == 100){
// loop through array and add totals
$total = '';
foreach($data_array AS $data){
$total += $data;
}
// get average
$avg = $total/count($data_array);
// store in a larger array
$final_array[] = $avg;
// clear
$data_array = array();
// reset
$j = 0;
}
$j++;
}
// get the average total time
$final_total = '';
foreach($final_array AS $fdata){
$final_total += $fdata;
}
echo $final_total/count($final_array);
?>Code: Select all
1 million iterations for each function
serialize
- without @
.000013448463916779
- with @
.000016017480611801
array_flip
- without @
.000010388954401016
- with @
.000013084985971451
array_reverse
- without @
.0000089243161678314
- with @
.00001143853521347