6 if {[llength $argv] != 3} {
7 puts "Usage: $argv0 handle path times"
10 A persistent storage handle (see [tsv::array bind] manpage).
12 The path to file containing lines in the form of "key<tab>val", where
13 key is a single-word and val is everyting else.
15 The number of times to reload the data from persistent storage.
17 This script reads lines of data from <path> and stores them into the
18 persistent storage described by <handle>. Values for duplicate keys are
19 handled as a lists. The persistent storage engine is then stress-tested by
20 reloading the whole store <times> times.
25 lassign $argv handle path times
28 set filename [string range $handle [string first : $handle]+1 end]
29 file delete -force $filename
31 ### Load and store tab-separated values
32 tsv::array bind a $handle
34 set start [clock milliseconds]
36 while {[gets $fd line] > 0} {
37 if {[string index $line 0] eq {#}} {
40 set tab [string first { } $line]
45 set k [string range $line 0 $tab-1]
46 set v [string range $line $tab+1 end]
48 if {![tsv::exists a $k]} {
54 puts "Stored $pairs pairs in [expr {[clock milliseconds]-$start}] milliseconds"
62 tsv::array bind a $handle
63 set pairs [tsv::array size a]
67 puts "Loaded $pairs pairs $times times at $iter"
70 puts "File $filename is [file size $filename] bytes long"