Re: convert numerical day of week
| From: | Greg Donald | Date: | Tue, 22 May 2007 22:13:46 +0000 |
| Subject: | Re: convert numerical day of week | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255352@lists.php.net to get a copy of this message | ||
On 5/22/07, Robert Cummings <robert@interjinn.com> wrote:
No, your solution is bloated. Mine may run a tad slower,Two function calls wrapped in a function will be slower. Tad or a lot, slower is still slower.
but it consumes less memory since it uses the weekday names already defined in the locale.Looks to me like your version consumes more memory:
ps aux|grep phpphp simple.phpdestiney 9448 0.0 -0.2 72596 4760 p2 S+ 4:40PM 0:00.03
destiney 9449 0.0 -0.2 72596 4852 p1 S+ 4:40PM 0:00.03php locale.php
Yours redefines the strings thus requiring that much extra storage. Yours is redundant with information already available in the locale.You're specializing for an edge case before you even know if you need to or not. As I've shown above memory is saved by defining your own list of days. I'm sure given the right conditions your function would be of great use. Maybe later on someone will actually ask about locales, then you can repost it and it can become relevant.
The YAGNI claim is irrelevant here since I'm producing the requested functionality that the poster obviously needs. Whether I use your method or my method is irrelevant to YAGNI.I'm looking at the original post and I still can't seem to find anything about locales in there. Locales only came into the thread when you posted your function.
Thank you, try again.My solution stands as the best one, for memory usage and speed. Please benchmark it so you will learn from this experience. -- Greg Donald http://destiney.com/