aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-07-01 16:26:18 +0200
committerLukas Larsson <[email protected]>2011-08-01 16:38:17 +0200
commit375b4f6a5c978cc0af93ce2fa4bcbd1dcc02978c (patch)
tree73999f9316a2f4cb39fc71135749c72003170bc5 /lib/asn1
parent4eb3b480476a9345206bbd74f0f60ed9abae1f34 (diff)
downloadotp-375b4f6a5c978cc0af93ce2fa4bcbd1dcc02978c.tar.gz
otp-375b4f6a5c978cc0af93ce2fa4bcbd1dcc02978c.tar.bz2
otp-375b4f6a5c978cc0af93ce2fa4bcbd1dcc02978c.zip
Add nif vs driver vs erlang performance tests for per encode and ber decode.
Results now suggest that nifs are 15% faster than driver for per and 5% faster for ber. Erlang is inbetween nif and driver for ber, but about 50% slower than driver for per.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/test/asn1_bin_v2_particular_SUITE.erl.src73
1 files changed, 72 insertions, 1 deletions
diff --git a/lib/asn1/test/asn1_bin_v2_particular_SUITE.erl.src b/lib/asn1/test/asn1_bin_v2_particular_SUITE.erl.src
index 2c23573eec..55e40e6a77 100644
--- a/lib/asn1/test/asn1_bin_v2_particular_SUITE.erl.src
+++ b/lib/asn1/test/asn1_bin_v2_particular_SUITE.erl.src
@@ -1,5 +1,5 @@
-particular() -> [smp, ticket7904].
+particular() -> [smp, per_performance, ber_performance, ticket7904].
smp(suite) -> [];
@@ -38,6 +38,77 @@ smp(Config) ->
{skipped,"No smp support"}
end.
+per_performance(Config) ->
+
+ ?line Msg = {initiatingMessage, testNBAPsystem:cell_setup_req_msg()},
+ ?line ok = testNBAPsystem:compile(Config,per_bin,[optimize]),
+ N = 10000,
+
+ ?line ok = asn1rt:load_driver(),
+
+ asn1_wrapper:encode('NBAP-PDU-Discriptions','NBAP-PDU', Msg),
+
+ PerFun = fun() ->
+ [asn1_wrapper:encode('NBAP-PDU-Discriptions',
+ 'NBAP-PDU',
+ Msg) || _I <- lists:seq(1,N)],
+ ok
+ end,
+
+ ?line {TimeD,ok} = timer:tc(PerFun),
+
+ ?line ok = testNBAPsystem:compile(Config,per_bin,[optimize,nif]),
+
+ ?line {TimeN,ok} = timer:tc(PerFun),
+
+ ?line ok = testNBAPsystem:compile(Config,per_bin,[]),
+
+ ?line {TimeE,ok} = timer:tc(PerFun),
+
+ {comment, lists:flatten(io_lib:format("Driver: ~p<br/>"
+ "Nif : ~p<br/>"
+ "Erlang: ~p",[TimeD, TimeN, TimeE]))}.
+
+ber_performance(Config) ->
+
+ ?line Msg = {initiatingMessage, testNBAPsystem:cell_setup_req_msg()},
+ ?line ok = testNBAPsystem:compile(Config,ber_bin,[optimize,driver]),
+ N = 10000, S = 1,
+
+ ?line ok = asn1rt:load_driver(),
+
+ {ok,B} = asn1_wrapper:encode('NBAP-PDU-Discriptions','NBAP-PDU', Msg),
+
+ PerFun = fun() ->
+ [begin
+ [asn1_wrapper:decode(
+ 'NBAP-PDU-Discriptions',
+ 'NBAP-PDU',
+ B) || _I <- lists:seq(1,round(N/100))],
+ timer:sleep(S)
+ end || _I0 <- lists:seq(1,100)],
+ ok
+ end,
+
+ ?line {TimeD,ok} = timer:tc(PerFun),
+
+ ?line ok = testNBAPsystem:compile(Config,ber_bin,[optimize,nif]),
+
+ ?line {TimeN,ok} = timer:tc(PerFun),
+
+ ?line ok = testNBAPsystem:compile(Config,ber_bin,[optimize]),
+
+ ?line {TimeE,ok} = timer:tc(PerFun),
+
+ {comment, lists:flatten(io_lib:format("Driver: ~p<br/>"
+ "Nif : ~p<br/>"
+ "Erlang: ~p",[TimeD-100*S,
+ TimeN-100*S,
+ TimeE-100*S]))}.
+
+
+
+
smp2(Parent,NumOfProcs,Msg, N) ->
Pids = [spawn_link(fun() -> worker(Msg,Parent, N) end)
|| _ <- lists:seq(1,NumOfProcs)],