Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
36e790a0
Commit
36e790a0
authored
Jul 10, 2011
by
antirez
Browse files
print execution time of different units at end
parent
13566085
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_helper.tcl
View file @
36e790a0
...
@@ -54,7 +54,7 @@ proc execute_tests name {
...
@@ -54,7 +54,7 @@ proc execute_tests name {
set path
"tests/
$name.tcl
"
set path
"tests/
$name.tcl
"
set ::curfile $path
set ::curfile $path
source $path
source $path
send_data_packet $::test_server_fd done
"
$name
finished
"
send_data_packet $::test_server_fd done
"
$name
"
}
}
# Setup a list to hold a stack of server configs. When calls to start_server
# Setup a list to hold a stack of server configs. When calls to start_server
...
@@ -174,6 +174,8 @@ proc test_server_main {} {
...
@@ -174,6 +174,8 @@ proc test_server_main {} {
# Setup global state for the test server
# Setup global state for the test server
set ::idle_clients
{}
set ::idle_clients
{}
set ::active_clients
{}
set ::active_clients
{}
array set ::clients_start_time
{}
set ::clients_time_history
{}
# Enter the event loop to handle clients I/O
# Enter the event loop to handle clients I/O
after 100 test_server_cron
after 100 test_server_cron
...
@@ -211,8 +213,10 @@ proc read_from_test_client fd {
...
@@ -211,8 +213,10 @@ proc read_from_test_client fd {
if
{
$status
eq
{
ready
}}
{
if
{
$status
eq
{
ready
}}
{
signal_idle_client $fd
signal_idle_client $fd
}
elseif
{
$status
eq
{
done
}}
{
}
elseif
{
$status
eq
{
done
}}
{
set elapsed
[
expr
{[
clock seconds
]
-$::clients_start_time
(
$fd
)}]
puts
"+++
[
llength $::active_clients
]
units still in execution (
$elapsed
seconds)."
lappend ::clients_time_history $elapsed $data
signal_idle_client $fd
signal_idle_client $fd
puts
"+++
[
llength $::active_clients
]
units still in execution."
}
}
}
}
...
@@ -225,6 +229,7 @@ proc signal_idle_client fd {
...
@@ -225,6 +229,7 @@ proc signal_idle_client fd {
# New unit to process?
# New unit to process?
if
{
$::next
_test !=
[
llength $::all_tests
]}
{
if
{
$::next
_test !=
[
llength $::all_tests
]}
{
puts
"Spawing new test process for:
[
lindex $::all_tests $::next_test
]
"
puts
"Spawing new test process for:
[
lindex $::all_tests $::next_test
]
"
set ::clients_start_time
(
$fd
)
[
clock seconds
]
send_data_packet $fd run
[
lindex $::all_tests $::next_test
]
send_data_packet $fd run
[
lindex $::all_tests $::next_test
]
lappend ::active_clients $fd
lappend ::active_clients $fd
incr ::next_test
incr ::next_test
...
@@ -240,7 +245,11 @@ proc signal_idle_client fd {
...
@@ -240,7 +245,11 @@ proc signal_idle_client fd {
# executed, so the test finished.
# executed, so the test finished.
proc the_end
{}
{
proc the_end
{}
{
# TODO: print the status, exit with the rigth exit code.
# TODO: print the status, exit with the rigth exit code.
puts
"The End"
puts
"The End
\n
"
puts
"Execution time of different units:"
foreach
{
time name
}
$::clients_time_history
{
puts
"
$time
seconds -
$name
"
}
exit 1
exit 1
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment