note 105561 added to language.constants

From: Date: Sat, 27 Aug 2011 17:57:11 +0000
Subject: note 105561 added to language.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-182769@lists.php.net to get a copy of this message
In reply to meint at meint dot net: I had code like this: $flag and $i++; I bench tested it against this: if ($flag) $i++; in a loop of 10000 times. I ran the test 20+ times. It consistently yielded faster times to use "if" (I forget by how much, but enough to make a difference to me). I suppose this is because there is one or two more steps of operations and of throwing a value on the system stack (the final boolean combined value of ($flag and $i++)) using "and", or something like that. Somewheres else on this site I read how PHP was tuned to make "if" work as fast as possible. Even though it must evaluate the opcode of "if", it must also evaluate and execute the opcode "and", which may be farther down on the "list of opcodes" and the "address table" for each opcode. In other words, it may work harder just to understand that you mean "and" in the first place. The first way sure does look nice though! ---- Server IP: 69.147.83.197 Probable Submitter: 74.160.228.23 ---- Manual Page -- http://www.php.net/manual/en/language.constants.php Edit -- https://master.php.net/note/edit/105561 Del: integrated -- https://master.php.net/note/delete/105561/integrated Del: useless -- https://master.php.net/note/delete/105561/useless Del: bad code -- https://master.php.net/note/delete/105561/bad+code Del: spam -- https://master.php.net/note/delete/105561/spam Del: non-english -- https://master.php.net/note/delete/105561/non-english Del: in docs -- https://master.php.net/note/delete/105561/in+docs Del: other reasons-- https://master.php.net/note/delete/105561 Reject -- https://master.php.net/note/reject/105561 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182769) next »