Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13480 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74534 invoked by uid 1010); 22 Oct 2004 23:34:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 74439 invoked from network); 22 Oct 2004 23:34:36 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 22 Oct 2004 23:34:36 -0000 Received: (qmail 5781 invoked from network); 22 Oct 2004 23:34:34 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 22 Oct 2004 23:34:34 -0000 Message-ID: <5.1.0.14.2.20041022163333.031320d0@localhost> X-Sender: andi@localhost X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 22 Oct 2004 16:35:18 -0700 To: dharana ,Ilia Alshanetsky Cc: internals@lists.php.net In-Reply-To: <41797423.4060405@dharana.net> References: <417970E3.7080001@prohost.org> <417970E3.7080001@prohost.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] PHP 5.1 time() caching From: andi@zend.com (Andi Gutmans) At 10:57 PM 10/22/2004 +0200, dharana wrote: >Ilia Alshanetsky wrote: > >>As of PHP 5.1, the request start time is stored by PHP inside the sapi >>structure. This data is populated by the information offered by the SAPI >>(Apache sapis populate it) otherwise time(0) is used to get the same data. >>This means that PHP has a "free" unix timestamp that tells information >>about the request start time, which does not require a syscall. >>. Since a lot of script end up having to fetch request start time, this >>can be used to save on a timing call >>(This information only has second precision, no microseconds). > >I would think the reason for fetching request start time is to profile >execution time (the first line you would see in my scripts is always >$time_start = microtime()) or maybe it's just me, of course. I think using current time for timestamps in DBs and so on can be very useful. I think Ilia had in mind wider use and not specifically for profiling where the performance of the initial call to time() wouldn't have any significance. >>The question is what would be the best way to provide this information >>within the script. The two alternatives are: adding a new function to get >>this info or storing this data inside $_SERVER. > >I'm for $_SERVER, it makes most sense for me. $_SERVER[] is fine. The downside that it's an extra hash_update() on each requests even if you don't use the time (as opposed to an internal function). But in real life this would not be noticeable. Andi