|
Posted by Andrι Medeiros on 06/29/05 23:56
People have fun with the oddest things ;)
Anyway, it's a nice reference to have around :)
On 6/29/05, Philip Hallstrom <php@philip.pjkh.com> wrote:
> > OK OK I got it ;)
> >
> > I just suggested it because I thought he could assume that "www."
> > would always be on the string.
> >
> > Either way, I guess _one_ preg_replace is alright.
>
> Heh :-) Just for kicks...
>
> - randomly prefix "www." onto 1324 proper names (dictionary file). 659 end
> up with "www." prefixed.
>
> - wrote a script to load them all up into an array, then loop through
> doing an ereg, substr, and preg. Each block looks like this:
>
> reset($ary);
> $stime = microtime(true);
> foreach ( $ary as $w ) {
> $w = ereg_replace("^www\.", "", $w);
> }
> $etime = microtime(true);
> $ttime = $etime - $stime;
> print("ereg_replace: $ttime\n");
>
> The only differenec being the line in the foreach loop.
>
> Ran it several times on a fairly quite box and always got pretty similar
> results...
>
> ereg_replace: 0.0057849884033203
> substr: 0.0025739669799805
> preg_replace: 0.004335880279541
>
> Anyway... there's some stats for the archive :-)
>
> >
> > On 6/29/05, Kevin L'Huillier <klhuillier@gmail.com> wrote:
> >>>> Wouldn't
> >>>>
> >>>> $newUrl = 'https://' . substr( $_SERVER['SERVER_NAME'], 4 ) .........
> >>>>
> >>>> be a _hell_ of a lot faster?
> >>>
> >>> If one considers micro-seconds 'a _hell_ of a lot faster', then _maybe_
> >>
> >> And it could be slower if you avoid sending someone from
> >> http://example.com/ to https://ple.com/ by adding a substring
> >> check.
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
[Back to original message]
|