Fossil

Check-in [08f5fb62]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the "--threads N" option to the fossil-stress.tcl script. Default value is 10.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 08f5fb624124eaa88499d8d5b65db24e8f1e8399ba9ea297a24909b4af5ccc6f
User & Date: drh 2017-12-28 15:49:23.321
Context
2017-12-28
16:04
In fossil-stress.tcl, retry connection failures after a 1-second delay. ... (check-in: 7ce35a04 user: drh tags: trunk)
15:49
Add the "--threads N" option to the fossil-stress.tcl script. Default value is 10. ... (check-in: 08f5fb62 user: drh tags: trunk)
13:53
Add the fossil-stress.tcl script for stress-testing server implementations. ... (check-in: 0a6d8ff5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to tools/fossil-stress.tcl.
1
2
3
4
5
6
7














8


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

36
37
38

39






40
41




42
43
44
45
46
47
48
#!/usr/bin/tclsh
#
# Run this script, giving the url of a Fossil server instances as the
# argument, and this script will start sending HTTP requests into the
# that server instance as fast as it can, as a stress test for the
# server implementation.
#














set url [lindex $argv 0]


if {$url==""} {
  error "Usage: $argv0 URL"
}
if {![regexp {^https?://([^/:]+)(:\d+)?(/.*)$} $url all domain port path]} {
  error "could not parse the URL [list $url] -- should be of the\
         form \"http://domain/path\""
}
set useragent {Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0}
set path [string trimright $path /]
set port [string trimleft $port :]
if {$port==""} {set port 80}

proc send_one_request {domain port path} {
  set x [socket $domain $port]
  fconfigure $x -translation binary
  puts $x "GET $path HTTP/1.0\r"
  if {$port==80} {
    puts $x "Host: $domain\r"
  } else {
    puts $x "Host: $domain:$port\r"
  }
  puts $x "User-Agent: $::useragent\r"
  puts $x "Accept: text/html,q=0.9,*/*;q=0.8\r"
  puts $x "Accept-Language: en-US,en;q=0.5\r"
  puts $x "Connection: close\r"
  puts $x "\r"
  flush $x

  set cnt 0
  while {![eof $x]} {
    incr cnt [string length [read $x]]

  }






  close $x
  return $cnt




}

set pages {
  /timeline?n=20
  /timeline?n=20&a=1970-01-01
  /home
  /brlist







>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|
|










|














>
|
|
<
>
|
>
>
>
>
>
>
|
|
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/tclsh
#
# Run this script, giving the url of a Fossil server instances as the
# argument, and this script will start sending HTTP requests into the
# that server instance as fast as it can, as a stress test for the
# server implementation.
#
set nthread 10
for {set i 0} {$i<[llength $argv]} {incr i} {
  set x [lindex $argv $i]
  if {[regexp {^--[a-z]} $x]} {
    set x [string range $x 1 end]
  }
  if {$x=="-threads"} {
    incr i
    set nthread [lindex $argv $i]
  } elseif {[string index $x 0]=="-"} {
    error "unknown option \"$x\""
  } elseif {[info exists url]} {
    error "unknown argment \"$x\""
  } else {
    set url $x
  }
}
if {![info exists url]} {
  error "Usage: $argv0 [-threads N] URL"
}
if {![regexp {^https?://([^/:]+)(:\d+)?(/.*)$} $url all domain port path]} {
  error "could not parse the URL [list $url] -- should be of the\
         form \"http://domain/path\""
}
set useragent {Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0}
set path [string trimright $path /]
set port [string trimleft $port :]
if {$port==""} {set port 80}

proc send_one_request {tid domain port path} {
  set x [socket $domain $port]
  fconfigure $x -translation binary
  puts $x "GET $path HTTP/1.0\r"
  if {$port==80} {
    puts $x "Host: $domain\r"
  } else {
    puts $x "Host: $domain:$port\r"
  }
  puts $x "User-Agent: $::useragent\r"
  puts $x "Accept: text/html,q=0.9,*/*;q=0.8\r"
  puts $x "Accept-Language: en-US,en;q=0.5\r"
  puts $x "Connection: close\r"
  puts $x "\r"
  flush $x
  global cnt
  set cnt($x) 0
  fconfigure $x -blocking 0

  fileevent $x readable [list get_reply $tid $path $x]
}

proc get_reply {tid info x} {
  global cnt
  if {[eof $x]} {
    puts "[format %3d: $tid] $info ($cnt($x) bytes)"
    flush stdout
    close $x
    unset cnt($x)
    start_another_request $tid
  } else {
    incr cnt($x) [string length [read $x]]
  }
}

set pages {
  /timeline?n=20
  /timeline?n=20&a=1970-01-01
  /home
  /brlist
65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81




  /md_rules
  /help
  /test-all-help
  /timewarps
  /taglist
}

set cnt 0
while {1} {

  foreach p $pages {
    incr cnt
    puts -nonewline "$cnt: $path$p... "
    flush stdout
    set n [send_one_request $domain $port $path$p]
    puts "$n bytes"
  }
}











|
|
>
|
|
|
<
|
<
|
|
>
>
>
>
92
93
94
95
96
97
98
99
100
101
102
103
104

105

106
107
108
109
110
111
  /md_rules
  /help
  /test-all-help
  /timewarps
  /taglist
}

set pageidx 0
proc start_another_request {tid} {
  global pages pageidx domain port path
  set p [lindex $pages $pageidx]
  incr pageidx
  if {$pageidx>=[llength $pages]} {set pageidx 0}

  send_one_request $tid $domain $port $path$p

}

for {set i 1} {$i<=$nthread} {incr i} {
  start_another_request $i
}
vwait forever