aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2010-07-07 10:46:48 +0200
committerRaimo Niskanen <[email protected]>2010-07-07 10:46:48 +0200
commita1a9aff12c1365dc155328410c5253d7495f757f (patch)
treeb7b12d6f7cd38f94702bbc946d9671b9583d2738 /lib/stdlib/test
parent0aa94b3b70ae9bd99e23f99e51f08d694403fd21 (diff)
parent2cca6506bafedc5ebb720510151a98602133d8e5 (diff)
downloadotp-a1a9aff12c1365dc155328410c5253d7495f757f.tar.gz
otp-a1a9aff12c1365dc155328410c5253d7495f757f.tar.bz2
otp-a1a9aff12c1365dc155328410c5253d7495f757f.zip
Merge branch 'cf/timer_tc' into dev
* cf/timer_tc: Add timer:tc/2 to measure the elapsed time of anonymous functions Conflicts: lib/stdlib/doc/src/timer.xml
Diffstat (limited to 'lib/stdlib/test')
-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,