I read over several php performance blogs that for performance issues it is batter to call $_SERVER['REQUEST_TIME'] instead of time() to get the current unix timestamp. But ( at least in Drupal 5.7) look what i get:
# grep -R 'time()' . | wc -l
# 104
This is with my custom modules added, so probably the result is with an error of +5 calls to time().
Anyway, i think there must be a real reason why we don't get the timestamp from $_SERVER['REQUEST_TIME'], but i cannot find it.

Thanks.

Comments

nevets’s picture

$_SERVER['REQUEST_TIME'] is static in that it represents the time the request was made, not the current time. As such it does not change over the life of a single page request.

andreiashu’s picture

Oki. Thanks for info. But shouldn't almost every request be delivered way under 1 second ? I mean does it really matter for us the exact second where we are at in the code ?
I'm not trying to be ignorant here but i'm a performance freak (even if i'm not so experienced with php) :) and try to squeeze every single bit of performance from my scripts.

Mgccl’s picture

time() is slow.
there are places where a page takes more than 1 second to load...
but time() uses so little time, it can be ignored...
-----------------
Mgccl's Blog

AjK’s picture