Testing slightly different python randomisation manoeuvres

  • From: Jacob Kruger <jacobk@xxxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Thu, 5 May 2011 16:19:50 +0200

Testing python randomising a number between 1 and 100, repeating process 100 
thousand times, the automatic integer output method took approximately 279 
milliseconds the slightly more involved (in terms of having to convert 
randomised number into a clean integer in the right range) method took 
approximately 59 milliseconds - the difference was 220 milliseconds slower if 
you asked it to automatically give you a number in the range 1 to 100, as 
opposed to taking the decimal/floating point number more automatically 
generated, and multiplying it then by 100, and converting it to an integer as 
such.

This is something that almost immediately popped up in my mind when was 
reviewing the various randomisation objects/methods provided by modules built 
into python, after had already made my own workaround for spitting out a clean 
integer between 1 and 100, and then thought of double checking if there was 
some or other built in/automatic process to generate one as such, and then I 
put together the little bit of code to test the differences in execution 
time...<smile>

Dunno why I thought of trying this out, since am actually just busy going 
through one of the learn python books, and while working through pieces on 
lists and dictionary objects, I was messing around with storing the full 
alphabet in these collection objects, and then spitting out a random letter, 
etc. etc., and it just ended up making me get around to thinking 
about/considering this.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: