Module egtm_util_eunit

EGTM EUnit Utilities.

Description

EGTM EUnit Utilities.

Function Index

perform_speed/1Performance testing: runs a tc_avg (Fun, Cnt) multiple times.
tc_avg/2Measure average execution time of specified function Fun with arity of 0.

Function Details

perform_speed/1

perform_speed(T) -> any()

Performance testing: runs a tc_avg (Fun, Cnt) multiple times. A typical use is to benchmark multiple functions and compare their average results on single screen.

A code of egtm:order_speed_test () unit test might be a good use-case example:
  order_speed_test () ->
    egtm:start (),
    egtm:do ("testPerfPrepare^%egtmapi()"),
 
    egtm_util_eunit:perform_speed ([
      {fun () -> egtm:zversion () end,
        50, "Erlang $ZVersion"},
      {fun () -> egtm:call ("testPerfOrder1^%egtmapi()") end,
        10, "Native $Order"},
      {fun () -> egtm:call ("testPerfOrder2^%egtmapi()") end,
        10, "Indirection-based"},
      {fun () -> egtm:call ("testPerfOrder3^%egtmapi()") end,
        10, "Xecute-based"},
      {fun () -> egtm_util_eunit:order_loop (egtm, indirection, 100) end,
        5, "Erlang Indirection-based"},
      {fun () -> egtm_util_eunit:order_loop (egtm, call_xecute, 100) end,
        5, "Erlang Call-Xecute-based"},
      {fun () -> egtm_util_eunit:order_loop (egtm, xecute, 100) end,
        5, "Erlang Xecute-based"},
      {fun () -> egtm_util_eunit:order_loop (egtm, erl_xecute, 100) end,
        5, "Erlang ErlXecute-based"}
    ]),
 
    egtm:stop (),
    ok.

tc_avg/2

tc_avg(Fun, Count) -> any()

Measure average execution time of specified function Fun with arity of 0. The number of time-sampling runs is specified by Count argument.

Example:
  erl> egtm_util_eunit:tc_avg (fun () ->
         io:format ("T=~p~n", [now ()]) end, 5).
  T={1339,133634,737039}
  T={1339,133634,737079}
  T={1339,133634,737105}
  T={1339,133634,737125}
  T={1339,133634,737147}
  21.1875


Generated by EDoc, Aug 19 2012, 02:27:27.