| 1 |
set test "optim_stats" |
| 2 |
|
| 3 |
# This test is a literal benchmark that asserts a speedup in various modes of |
| 4 |
# the runtime. Let's consider two stap scripts. Script A: |
| 5 |
# |
| 6 |
# global a |
| 7 |
# a <<< 3 |
| 8 |
# a <<< 4 |
| 9 |
# a <<< 5 |
| 10 |
# println(@count(a)) |
| 11 |
# |
| 12 |
# And script B: |
| 13 |
# |
| 14 |
# global b |
| 15 |
# b <<< 3 |
| 16 |
# b <<< 4 |
| 17 |
# b <<< 5 |
| 18 |
# println(@variance(b)) |
| 19 |
# |
| 20 |
# These two scripts take various run times t(A) and t(B). This test |
| 21 |
# essentially tries to make sure that t(A) < t(B). That's is because @count() |
| 22 |
# is computionally cheaper compared to @variance(). Both @count() and |
| 23 |
# @variance cause some incremental run time computation at every element |
| 24 |
# addition time. The stap runtime should optimize out unneeded computations, |
| 25 |
# so that at the script A run time no @variance() is computed. |
| 26 |
# |
| 27 |
# This similarly works with stats whose elements are arrays, e.g. a[1] <<< 3 |
| 28 |
# |
| 29 |
# This test tries to make sure that the above timing assumptions are true. |
| 30 |
|
| 31 |
if {![installtest_p]} { |
| 32 |
untested $test |
| 33 |
return |
| 34 |
} |
| 35 |
|
| 36 |
foreach runtime [get_runtime_list] { |
| 37 |
if {$runtime != ""} { |
| 38 |
spawn stap --runtime=$runtime -g --suppress-time-limits $srcdir/$subdir/$test.stp |
| 39 |
} else { |
| 40 |
spawn stap -g --suppress-time-limits $srcdir/$subdir/$test.stp |
| 41 |
} |
| 42 |
expect { |
| 43 |
-timeout 300 |
| 44 |
{TEST_PASS} { pass "$test $runtime" } |
| 45 |
{TEST_FAIL} { fail "$test $runtime" } |
| 46 |
timeout {fail "$test $runtime: unexpected timeout"} |
| 47 |
eof { } |
| 48 |
} |
| 49 |
catch {close}; catch {wait} |
| 50 |
} |