Fossil SCM

fossil-scm / test / many-www.tcl
Blame History Raw 82 lines
1
#!/usr/bin/tclsh
2
#
3
# Run this script from within any open Fossil checkout. Example:
4
#
5
# tclsh many-www.tcl | tee out.txt
6
#
7
# About 10,000 different web page requests will be made. Each is timed
8
# and the time shown on output. Use this script to search for segfault problems
9
# or to look for pages that need optimization.
10
#
11
proc run_query {url} {
12
set fd [open q.txt w]
13
puts $fd "GET $url HTTP/1.0\r\n\r"
14
close $fd
15
return [exec fossil test-http <q.txt]
16
}
17
set todo {}
18
foreach url {
19
/home
20
/timeline
21
/brlist
22
/taglist
23
/reportlist
24
/setup
25
/dir
26
/wcontent
27
/attachlist
28
/taglist
29
/test-env
30
/stat
31
/rcvfromlist
32
/urllist
33
/modreq
34
/info/d5c4
35
/test-all-help
36
/leaves
37
/timeline?a=1970-01-01
38
} {
39
set seen($url) 1
40
set pending($url) 1
41
}
42
set round 1
43
set limit 25000
44
set npending [llength [array names pending]]
45
proc get_pending {} {
46
global pending npending round next
47
if {$npending==0} {
48
incr round
49
array set pending [array get next]
50
set npending [llength [array names pending]]
51
unset -nocomplain next
52
}
53
set res [lindex [array names pending] [expr {int(rand()*$npending)}]]
54
unset pending($res)
55
incr npending -1
56
return $res
57
}
58
for {set i 0} {$i<$limit} {incr i} {
59
set url [get_pending]
60
puts -nonewline "($round/[expr {$i+1}]) $url "
61
flush stdout
62
set tm [time {set x [run_query $url]}]
63
set ms [lindex $tm 0]
64
puts [format {%.3fs} [expr {$ms/1000000.0}]]
65
flush stdout
66
if {[string length $x]>1000000} {
67
set x [string range $x 0 1000000]
68
}
69
set k 0
70
while {[regexp {<[aA] .*?href="(/[a-z].*?)".*?>(.*)$} $x all url tail]} {
71
# if {$npending>2*($limit - $i)} break
72
incr k
73
if {$k>100} break
74
set u2 [string map {&lt; < &gt; > &quot; \" &amp; &} $url]
75
if {![info exists seen($u2)]} {
76
set next($u2) 1
77
set seen($u2) 1
78
}
79
set x $tail
80
}
81
}
82

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button