Computing.Net > Forums > Unix > test generation problems

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

test generation problems

Reply to Message Icon

Name: elpico
Date: January 31, 2005 at 09:22:35 Pacific
OS: Solaris
CPU/Ram: 256
Comment:

Hi all,

I'm creating a script to try and generate large volumes of test data. Now, the problem is that its not the most efficient, I've used mainly ksh to do this.

My test data needs to include some unique data, which I've done by incrementing stuff, which is fine. Where I think its severly slowing down the processing is that I'm using the $RANDOM variable to generate random data

# My script
create_rand_txn_amnt()
{

val=$RANDOM
pounds=`echo $val | cut -c1-3`
pence=`echo $val | cut -c4-5`
echo "${pounds}.${pence}"
}

#call the script within a loop
x=0
while [ $x -lt 300000 ]
do
amount=`create_rand_txn_amt`
print -n "${amount}$othervalues $morevalues"\n
done

#####################

I'm a bit rusty with the unix scripting, and so I'm hoping someone can suggest a way I can do this a lot quicker - I'm thinking arrays of values (It doens't really have to be totally random), but I'm not sure where to go with it.

Cheers,
k.




Sponsored Link
Ads by Google

Response Number 1
Name: thepubba
Date: January 31, 2005 at 09:39:39 Pacific
Reply:

Lose all that cut and echo stuff. If you are using ksh, try:

Counter=0
typeset -L3 pounds
typeset -R2 pence

while [[ $Counter -le 30000 ]]
do
VAL=$RANDOM
pounds=$VAL
pence=$VAL
print $pounds.$pence
(( Counter +=1 ))
done

Don't need all that cut and echo stuff. Your script is about as random as your're going to get while still keeping it simple.


0

Response Number 2
Name: elpico
Date: January 31, 2005 at 09:44:31 Pacific
Reply:

Thanks - I think your right - the echo comand was killing me!

Thanks again.

K.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: test generation problems

phonebook problem www.computing.net/answers/unix/phonebook-problem/7921.html

Uuencode problem in mail attachment www.computing.net/answers/unix/uuencode-problem-in-mail-attachment/7347.html

shell scripting problem help www.computing.net/answers/unix/shell-scripting-problem-help/4791.html