Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/nethome/users/drmb75/tclkit85-linux-x86
- ;#this generates sample files for testing
- ;#the multithreaded banking code for cs284
- ;#the user is expected to > this to whatever file they want
- ;#to store the output in
- ;#returns a random integer in the desired range
- proc rand_int {low high} {
- return [expr {int(rand()*($high-$low+1)+$low)}]
- }
- ;#variables to store various parameters
- ;#(none of which we are likely to change)
- set operations [list "d" "w" "t"]
- set accounts [list 0 1]
- set min_amount 1
- set max_amount 9000
- set lines 500
- for {set n 0} {$n<$lines} {incr n} {
- set op [lindex $operations [rand_int 0 [expr {[llength $operations]-1}]]]
- set account [lindex $accounts [rand_int 0 [expr {[llength $accounts]-1}]]]
- set amount [rand_int $min_amount $max_amount]
- ;#the newline thing here is just a formatting issue
- ;#because of how bank.c expects it
- puts -nonewline "$op $account $amount"
- if {$n!=[expr {$lines-1}]} {
- ;#this is just a newline
- puts ""
- }
- }
Add Comment
Please, Sign In to add comment