Re: [PHP] shuffle or mt_rand
- From: genphp@xxxxxxxxx (Ryan A)
- Date: Fri, 29 Jun 2007 08:20:46 -0700 (PDT)
Just did a quick benchmark for 10.000 hands (making a full deck on
your code, 23.5 players):
Microtime difference:
Ryan's code:15.725826978683
Tijnema's code:0.40006709098816
Unique decks out of 10000:
Ryan's code:10000
Tijnema's code:10000
When making a full deck my code is 40 times faster, and a lot less
memory intensive. And as you can see, for both all 10000 decks are
unique, so both are random :)
But, also when generating cards for only 4 players, my code is twice
as fast as yours, and both generate still 10000 random decks:
Microtime difference:
Ryan's code:0.82403707504272
Tijnema's code:0.40426802635193
Unique decks out of 10000:
Ryan's code:10000
Tijnema's code:10000
Hey Tijnema,
I really had no doubt about your code being faster and cleaner... (as i mentioned in my original post) but can you send me the benchmarking scripts that you used so i may test them a bit more?
Thanks!
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
---------------------------------
Don't be flakey. Get Yahoo! Mail for Mobile and
always stay connected to friends.
- Prev by Date: Re: Is this a php bug?
- Next by Date: Re: Is this a php bug?
- Previous by thread: Re: [PHP] PHP Brain Teasers [SPOILER]
- Next by thread: Flash / Ajax / PHP
- Index(es):
Relevant Pages
|