1
%% ``The contents of this file are subject to the Erlang Public License,
2
%% Version 1.1, (the "License"); you may not use this file except in
3
%% compliance with the License. You should have received a copy of the
4
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
7
%% Software distributed under the License is distributed on an "AS IS"
8
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
%% the License for the specific language governing rights and limitations
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
21
-include("bench.hrl").
23
-export([benchmarks/0]).
24
-export([local_call/1,external_call/1,fun_call/1,apply_fun/1,
25
apply_mfa_implicit/1, apply_mfa_explicit/1]).
29
{400000,[local_call,external_call,fun_call,apply_fun,
30
apply_mfa_implicit, apply_mfa_explicit]}.
40
external_call(Iter) ->
41
?rep40(?MODULE:foo()),
42
external_call(Iter-1).
45
fun_call(Iter, fun() -> ok end).
48
fun_call(Iter, Fun) ->
50
fun_call(Iter-1, Fun).
53
apply_fun(Iter, fun() -> ok end).
56
apply_fun(Iter, Fun) ->
57
?rep40(apply(Fun, [])),
58
apply_fun(Iter-1, Fun).
60
apply_mfa_explicit(0) ->
62
apply_mfa_explicit(Iter) ->
63
?rep40(apply(?MODULE, foo, [])),
64
apply_mfa_explicit(Iter-1).
66
apply_mfa_implicit(Iter) ->
67
apply_mfa_implicit(?MODULE, foo, Iter).
69
apply_mfa_implicit(_, _, 0) ->
71
apply_mfa_implicit(Module, Function, Iter) ->
72
?rep40(Module:Function()),
73
apply_mfa_implicit(Module, Function, Iter-1).