Edit report at http://bugs.php.net/bug.php?id=54249&edit=1

 ID:                 54249
 Updated by:         [email protected]
 Reported by:        amrnablus at gmail dot com
 Summary:            extra CPU operation on each usage or E_* error types
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
 Package:            Performance problem
 Operating System:   ALL
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

I think you are missing a few pieces here on how compilers work. Yes,
there is a 

preprocessor, but there is also a precompiler. The assembly generated by
your 

example looks like this:



    movl    $1, %esi

    leaq    LC0(%rip), %rdi

    xorl    %eax, %eax

    leave

    jmp _printf



That says, put 1 into esi, then call printf. That 1 came from 1<<0L. The


precompiler is smart enough to notice that this is an absolute constant
here.


Previous Comments:
------------------------------------------------------------------------
[2011-03-14 18:03:24] amrnablus at gmail dot com

Description:
------------
the way the errors are defined in zend_errors.h file makes an extra
unneeded cpu shift (multiplication?) operation each time the error
constant is used.



clue:

this is is from zend_errors.h:

#define E_ERROR                         (1<<0L)

if you printf( "%d" , E_ERROR ) the pre-processor will replace this line
with

printf( "%d" , 1<<0L ) which will cause an uncalled for shit operation

Test script:
---------------
/*

this script will cause a php E_NOTICE to be used, notice the (minor)
diff in execution time when error definitions are changed

*/



error_reporting( E_ALL );

for( $i=0 ; $i<10000000; $i++ ) {

        echo $x['a'];

}

Expected result:
----------------
no change to the output is a must



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54249&edit=1

Reply via email to