From: Wild Karl-Heinz Date: 2002-03-19T20:43:49+09:00 Subject: Random generated testdata ... Hallo, I use a script to generate test data. There are a routine to make sure that only one number will be generated. The method is not really fast. Is there an idea to make it faster? $names = IO.readlines( "/usr/share/dict/words" ); def getname ret = '' while String( ret ).length <= 0 ret = $names[ rand( $names.size ) ].chop.capitalize! end ret end # a new hash for saving unique numbers kfz_nr = Hash.new 100000.times do | i | nname = getname # This part seems to be slow kfz = rand( 999999 ); while kfz_nr[ kfz ] do kfz = rand( 999999 ); end kfz_nr[ kfz ] = 1 puts "Insert into cars Values (0, '#{nname}', #{kfz} );" end -- Karl-Heinz