+# Set a few configuration defaults
+set ::host 127.0.0.1
+set ::port 6379
+set ::stress 0
+set ::flush 0
+set ::first 0
+set ::last 1000000
+
+# Parse arguments
+for {set j 0} {$j < [llength $argv]} {incr j} {
+ set opt [lindex $argv $j]
+ set arg [lindex $argv [expr $j+1]]
+ set lastarg [expr {$arg eq {}}]
+ if {$opt eq {-h} && !$lastarg} {
+ set ::host $arg
+ incr j
+ } elseif {$opt eq {-p} && !$lastarg} {
+ set ::port $arg
+ incr j
+ } elseif {$opt eq {-stress}} {
+ set ::stress 1
+ } elseif {$opt eq {--flush}} {
+ set ::flush 1
+ } elseif {$opt eq {--first} && !$lastarg} {
+ set ::first $arg
+ incr j
+ } elseif {$opt eq {--last} && !$lastarg} {
+ set ::last $arg
+ incr j
+ } else {
+ echo "Wrong argument: $opt"
+ exit 1
+ }
+}
+