Fossil SCM
Add the "--threads N" option to the fossil-stress.tcl script. Default value is 10.
Commit
08f5fb624124eaa88499d8d5b65db24e8f1e8399ba9ea297a24909b4af5ccc6f
Parent
0a6d8ff505faea0…
1 file changed
+49
-19
+49
-19
| --- tools/fossil-stress.tcl | ||
| +++ tools/fossil-stress.tcl | ||
| @@ -3,13 +3,29 @@ | ||
| 3 | 3 | # Run this script, giving the url of a Fossil server instances as the |
| 4 | 4 | # argument, and this script will start sending HTTP requests into the |
| 5 | 5 | # that server instance as fast as it can, as a stress test for the |
| 6 | 6 | # server implementation. |
| 7 | 7 | # |
| 8 | -set url [lindex $argv 0] | |
| 9 | -if {$url==""} { | |
| 10 | - error "Usage: $argv0 URL" | |
| 8 | +set nthread 10 | |
| 9 | +for {set i 0} {$i<[llength $argv]} {incr i} { | |
| 10 | + set x [lindex $argv $i] | |
| 11 | + if {[regexp {^--[a-z]} $x]} { | |
| 12 | + set x [string range $x 1 end] | |
| 13 | + } | |
| 14 | + if {$x=="-threads"} { | |
| 15 | + incr i | |
| 16 | + set nthread [lindex $argv $i] | |
| 17 | + } elseif {[string index $x 0]=="-"} { | |
| 18 | + error "unknown option \"$x\"" | |
| 19 | + } elseif {[info exists url]} { | |
| 20 | + error "unknown argment \"$x\"" | |
| 21 | + } else { | |
| 22 | + set url $x | |
| 23 | + } | |
| 24 | +} | |
| 25 | +if {![info exists url]} { | |
| 26 | + error "Usage: $argv0 [-threads N] URL" | |
| 11 | 27 | } |
| 12 | 28 | if {![regexp {^https?://([^/:]+)(:\d+)?(/.*)$} $url all domain port path]} { |
| 13 | 29 | error "could not parse the URL [list $url] -- should be of the\ |
| 14 | 30 | form \"http://domain/path\"" |
| 15 | 31 | } |
| @@ -16,11 +32,11 @@ | ||
| 16 | 32 | set useragent {Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0} |
| 17 | 33 | set path [string trimright $path /] |
| 18 | 34 | set port [string trimleft $port :] |
| 19 | 35 | if {$port==""} {set port 80} |
| 20 | 36 | |
| 21 | -proc send_one_request {domain port path} { | |
| 37 | +proc send_one_request {tid domain port path} { | |
| 22 | 38 | set x [socket $domain $port] |
| 23 | 39 | fconfigure $x -translation binary |
| 24 | 40 | puts $x "GET $path HTTP/1.0\r" |
| 25 | 41 | if {$port==80} { |
| 26 | 42 | puts $x "Host: $domain\r" |
| @@ -31,16 +47,27 @@ | ||
| 31 | 47 | puts $x "Accept: text/html,q=0.9,*/*;q=0.8\r" |
| 32 | 48 | puts $x "Accept-Language: en-US,en;q=0.5\r" |
| 33 | 49 | puts $x "Connection: close\r" |
| 34 | 50 | puts $x "\r" |
| 35 | 51 | flush $x |
| 36 | - set cnt 0 | |
| 37 | - while {![eof $x]} { | |
| 38 | - incr cnt [string length [read $x]] | |
| 52 | + global cnt | |
| 53 | + set cnt($x) 0 | |
| 54 | + fconfigure $x -blocking 0 | |
| 55 | + fileevent $x readable [list get_reply $tid $path $x] | |
| 56 | +} | |
| 57 | + | |
| 58 | +proc get_reply {tid info x} { | |
| 59 | + global cnt | |
| 60 | + if {[eof $x]} { | |
| 61 | + puts "[format %3d: $tid] $info ($cnt($x) bytes)" | |
| 62 | + flush stdout | |
| 63 | + close $x | |
| 64 | + unset cnt($x) | |
| 65 | + start_another_request $tid | |
| 66 | + } else { | |
| 67 | + incr cnt($x) [string length [read $x]] | |
| 39 | 68 | } |
| 40 | - close $x | |
| 41 | - return $cnt | |
| 42 | 69 | } |
| 43 | 70 | |
| 44 | 71 | set pages { |
| 45 | 72 | /timeline?n=20 |
| 46 | 73 | /timeline?n=20&a=1970-01-01 |
| @@ -67,15 +94,18 @@ | ||
| 67 | 94 | /test-all-help |
| 68 | 95 | /timewarps |
| 69 | 96 | /taglist |
| 70 | 97 | } |
| 71 | 98 | |
| 72 | -set cnt 0 | |
| 73 | -while {1} { | |
| 74 | - foreach p $pages { | |
| 75 | - incr cnt | |
| 76 | - puts -nonewline "$cnt: $path$p... " | |
| 77 | - flush stdout | |
| 78 | - set n [send_one_request $domain $port $path$p] | |
| 79 | - puts "$n bytes" | |
| 80 | - } | |
| 81 | -} | |
| 99 | +set pageidx 0 | |
| 100 | +proc start_another_request {tid} { | |
| 101 | + global pages pageidx domain port path | |
| 102 | + set p [lindex $pages $pageidx] | |
| 103 | + incr pageidx | |
| 104 | + if {$pageidx>=[llength $pages]} {set pageidx 0} | |
| 105 | + send_one_request $tid $domain $port $path$p | |
| 106 | +} | |
| 107 | + | |
| 108 | +for {set i 1} {$i<=$nthread} {incr i} { | |
| 109 | + start_another_request $i | |
| 110 | +} | |
| 111 | +vwait forever | |
| 82 | 112 |
| --- tools/fossil-stress.tcl | |
| +++ tools/fossil-stress.tcl | |
| @@ -3,13 +3,29 @@ | |
| 3 | # Run this script, giving the url of a Fossil server instances as the |
| 4 | # argument, and this script will start sending HTTP requests into the |
| 5 | # that server instance as fast as it can, as a stress test for the |
| 6 | # server implementation. |
| 7 | # |
| 8 | set url [lindex $argv 0] |
| 9 | if {$url==""} { |
| 10 | error "Usage: $argv0 URL" |
| 11 | } |
| 12 | if {![regexp {^https?://([^/:]+)(:\d+)?(/.*)$} $url all domain port path]} { |
| 13 | error "could not parse the URL [list $url] -- should be of the\ |
| 14 | form \"http://domain/path\"" |
| 15 | } |
| @@ -16,11 +32,11 @@ | |
| 16 | set useragent {Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0} |
| 17 | set path [string trimright $path /] |
| 18 | set port [string trimleft $port :] |
| 19 | if {$port==""} {set port 80} |
| 20 | |
| 21 | proc send_one_request {domain port path} { |
| 22 | set x [socket $domain $port] |
| 23 | fconfigure $x -translation binary |
| 24 | puts $x "GET $path HTTP/1.0\r" |
| 25 | if {$port==80} { |
| 26 | puts $x "Host: $domain\r" |
| @@ -31,16 +47,27 @@ | |
| 31 | puts $x "Accept: text/html,q=0.9,*/*;q=0.8\r" |
| 32 | puts $x "Accept-Language: en-US,en;q=0.5\r" |
| 33 | puts $x "Connection: close\r" |
| 34 | puts $x "\r" |
| 35 | flush $x |
| 36 | set cnt 0 |
| 37 | while {![eof $x]} { |
| 38 | incr cnt [string length [read $x]] |
| 39 | } |
| 40 | close $x |
| 41 | return $cnt |
| 42 | } |
| 43 | |
| 44 | set pages { |
| 45 | /timeline?n=20 |
| 46 | /timeline?n=20&a=1970-01-01 |
| @@ -67,15 +94,18 @@ | |
| 67 | /test-all-help |
| 68 | /timewarps |
| 69 | /taglist |
| 70 | } |
| 71 | |
| 72 | set cnt 0 |
| 73 | while {1} { |
| 74 | foreach p $pages { |
| 75 | incr cnt |
| 76 | puts -nonewline "$cnt: $path$p... " |
| 77 | flush stdout |
| 78 | set n [send_one_request $domain $port $path$p] |
| 79 | puts "$n bytes" |
| 80 | } |
| 81 | } |
| 82 |
| --- tools/fossil-stress.tcl | |
| +++ tools/fossil-stress.tcl | |
| @@ -3,13 +3,29 @@ | |
| 3 | # Run this script, giving the url of a Fossil server instances as the |
| 4 | # argument, and this script will start sending HTTP requests into the |
| 5 | # that server instance as fast as it can, as a stress test for the |
| 6 | # server implementation. |
| 7 | # |
| 8 | set nthread 10 |
| 9 | for {set i 0} {$i<[llength $argv]} {incr i} { |
| 10 | set x [lindex $argv $i] |
| 11 | if {[regexp {^--[a-z]} $x]} { |
| 12 | set x [string range $x 1 end] |
| 13 | } |
| 14 | if {$x=="-threads"} { |
| 15 | incr i |
| 16 | set nthread [lindex $argv $i] |
| 17 | } elseif {[string index $x 0]=="-"} { |
| 18 | error "unknown option \"$x\"" |
| 19 | } elseif {[info exists url]} { |
| 20 | error "unknown argment \"$x\"" |
| 21 | } else { |
| 22 | set url $x |
| 23 | } |
| 24 | } |
| 25 | if {![info exists url]} { |
| 26 | error "Usage: $argv0 [-threads N] URL" |
| 27 | } |
| 28 | if {![regexp {^https?://([^/:]+)(:\d+)?(/.*)$} $url all domain port path]} { |
| 29 | error "could not parse the URL [list $url] -- should be of the\ |
| 30 | form \"http://domain/path\"" |
| 31 | } |
| @@ -16,11 +32,11 @@ | |
| 32 | set useragent {Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0} |
| 33 | set path [string trimright $path /] |
| 34 | set port [string trimleft $port :] |
| 35 | if {$port==""} {set port 80} |
| 36 | |
| 37 | proc send_one_request {tid domain port path} { |
| 38 | set x [socket $domain $port] |
| 39 | fconfigure $x -translation binary |
| 40 | puts $x "GET $path HTTP/1.0\r" |
| 41 | if {$port==80} { |
| 42 | puts $x "Host: $domain\r" |
| @@ -31,16 +47,27 @@ | |
| 47 | puts $x "Accept: text/html,q=0.9,*/*;q=0.8\r" |
| 48 | puts $x "Accept-Language: en-US,en;q=0.5\r" |
| 49 | puts $x "Connection: close\r" |
| 50 | puts $x "\r" |
| 51 | flush $x |
| 52 | global cnt |
| 53 | set cnt($x) 0 |
| 54 | fconfigure $x -blocking 0 |
| 55 | fileevent $x readable [list get_reply $tid $path $x] |
| 56 | } |
| 57 | |
| 58 | proc get_reply {tid info x} { |
| 59 | global cnt |
| 60 | if {[eof $x]} { |
| 61 | puts "[format %3d: $tid] $info ($cnt($x) bytes)" |
| 62 | flush stdout |
| 63 | close $x |
| 64 | unset cnt($x) |
| 65 | start_another_request $tid |
| 66 | } else { |
| 67 | incr cnt($x) [string length [read $x]] |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | set pages { |
| 72 | /timeline?n=20 |
| 73 | /timeline?n=20&a=1970-01-01 |
| @@ -67,15 +94,18 @@ | |
| 94 | /test-all-help |
| 95 | /timewarps |
| 96 | /taglist |
| 97 | } |
| 98 | |
| 99 | set pageidx 0 |
| 100 | proc start_another_request {tid} { |
| 101 | global pages pageidx domain port path |
| 102 | set p [lindex $pages $pageidx] |
| 103 | incr pageidx |
| 104 | if {$pageidx>=[llength $pages]} {set pageidx 0} |
| 105 | send_one_request $tid $domain $port $path$p |
| 106 | } |
| 107 | |
| 108 | for {set i 1} {$i<=$nthread} {incr i} { |
| 109 | start_another_request $i |
| 110 | } |
| 111 | vwait forever |
| 112 |