note 79288 added to function.posix-getpid

From: Date: Mon, 19 Nov 2007 22:07:11 +0000
Subject: note 79288 added to function.posix-getpid
Groups: php.notes 
Request: Send a blank email to php-notes+get-132411@lists.php.net to get a copy of this message
What is the difference between posix_getpid() and getmypid()? It appears that they're implemented differently. I wrote this quick test script: <?php $max = 1000000; $arr = array(); $a_0 = microtime(TRUE); for ($i=0; $i<$max; $i++) { $arr[] = getmypid(); } $a_1 = microtime(TRUE); $arr = array(); $b_0 = microtime(TRUE); for ($i=0; $i<$max; $i++) { $arr[] = posix_getpid(); } $b_1 = microtime(TRUE); $diff_a = $a_1 - $a_0; $diff_b = $b_1 - $b_0; echo "A: $diff_a, B: $diff_b: " . ($diff_b / $diff_a) . "\n"; ?> I ran this a number of times, and time got results similar to this: A: 1.1289880275726, B: 1.1726188659668: 1.0386459708417 So it's around 4% faster to use getmypid(). ---- Server IP: 69.147.83.197 Probable Submitter: 152.160.38.65 ---- Manual Page -- http://www.php.net/manual/en/function.posix-getpid.php Edit -- https://master.php.net/note/edit/79288 Del: integrated -- https://master.php.net/note/delete/79288/integrated Del: useless -- https://master.php.net/note/delete/79288/useless Del: bad code -- https://master.php.net/note/delete/79288/bad+code Del: spam -- https://master.php.net/note/delete/79288/spam Del: non-english -- https://master.php.net/note/delete/79288/non-english Del: in docs -- https://master.php.net/note/delete/79288/in+docs Del: other reasons-- https://master.php.net/note/delete/79288 Reject -- https://master.php.net/note/reject/79288 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132411) next »