aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/timer_simple_SUITE.erl
diff options
context:
space:
mode:
authorChristopher Faulet <[email protected]>2010-04-06 22:39:14 +0200
committerBjörn Gustavsson <[email protected]>2010-04-09 14:57:15 +0200
commit2cca6506bafedc5ebb720510151a98602133d8e5 (patch)
treeb34db2ee7fc3750a914330a2c692f6b06b7540bd /lib/stdlib/test/timer_simple_SUITE.erl
parente44595eab24f92fe33d1feea44e422bcb7c53824 (diff)
downloadotp-2cca6506bafedc5ebb720510151a98602133d8e5.tar.gz
otp-2cca6506bafedc5ebb720510151a98602133d8e5.tar.bz2
otp-2cca6506bafedc5ebb720510151a98602133d8e5.zip
Add timer:tc/2 to measure the elapsed time of anonymous functions
Works like timer:tc/3 but for anonymous functions.
Diffstat (limited to 'lib/stdlib/test/timer_simple_SUITE.erl')
-rw-r--r--lib/stdlib/test/timer_simple_SUITE.erl18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/stdlib/test/timer_simple_SUITE.erl b/lib/stdlib/test/timer_simple_SUITE.erl
index 021a22c61b..6aa2b7b945 100644
--- a/lib/stdlib/test/timer_simple_SUITE.erl
+++ b/lib/stdlib/test/timer_simple_SUITE.erl
@@ -224,11 +224,19 @@ cancel2(Config) when is_list(Config) ->
tc(doc) -> "Test sleep/1 and tc/3.";
tc(suite) -> [];
tc(Config) when is_list(Config) ->
- % This should both sleep and tc
- ?line {Res, ok} = timer:tc(timer, sleep, [500]),
- ?line ok = if
- Res < 500*1000 -> {too_early, Res}; % Too early
- Res > 800*1000 -> {too_late, Res}; % Too much time
+ % This should both sleep and tc/3
+ ?line {Res1, ok} = timer:tc(timer, sleep, [500]),
+ ?line ok = if
+ Res1 < 500*1000 -> {too_early, Res1}; % Too early
+ Res1 > 800*1000 -> {too_late, Res1}; % Too much time
+ true -> ok
+ end,
+
+ % This should both sleep and tc/2
+ ?line {Res2, ok} = timer:tc(fun(T) -> timer:sleep(T) end, [500]),
+ ?line ok = if
+ Res2 < 500*1000 -> {too_early, Res2}; % Too early
+ Res2 > 800*1000 -> {too_late, Res2}; % Too much time
true -> ok
end,