From 375b4f6a5c978cc0af93ce2fa4bcbd1dcc02978c Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 1 Jul 2011 16:26:18 +0200 Subject: 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. --- lib/asn1/test/asn1_bin_v2_particular_SUITE.erl.src | 73 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'lib/asn1/test') 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
" + "Nif : ~p
" + "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
" + "Nif : ~p
" + "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)], -- cgit v1.2.3