From 953b858de46f46f42e2ba45ba30a9b0b278a526d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 17 Dec 2012 16:25:59 +0100 Subject: Remove the 'inline' and '{inline,OutputFile}' options --- lib/asn1/doc/src/asn1_ug.xml | 43 +----- lib/asn1/doc/src/asn1ct.xml | 24 +-- lib/asn1/src/asn1ct.erl | 115 ++------------ lib/asn1/src/asn1ct_gen.erl | 8 +- lib/asn1/test/Makefile | 1 - lib/asn1/test/asn1_SUITE.erl | 41 +---- lib/asn1/test/asn1_test_lib.erl | 15 +- lib/asn1/test/testSSLspecs.erl | 23 +-- lib/asn1/test/test_compile_options.erl | 10 +- lib/asn1/test/test_inline.erl | 270 --------------------------------- lib/public_key/asn1/Makefile | 2 +- 11 files changed, 49 insertions(+), 503 deletions(-) delete mode 100644 lib/asn1/test/test_inline.erl diff --git a/lib/asn1/doc/src/asn1_ug.xml b/lib/asn1/doc/src/asn1_ug.xml index 6cb251c3e2..ecca287670 100644 --- a/lib/asn1/doc/src/asn1_ug.xml +++ b/lib/asn1/doc/src/asn1_ug.xml @@ -352,22 +352,6 @@ erlc -o ../asnfiles -I ../asnfiles -I /usr/local/standards/asn1 Person.asn list or a binary. Earlier versions of the compiler ignored those following bytes.

- {inline,OutputName} - -

Compiling with this option gives one output module - containing all asn1 run-time functionality. The asn1 specs - are provided in a target module Module.set.asn as - described in the reference manual. The name of the resulting module - containing generated encode/decode functions and inlined - run-time functions will be OutputName.erl. The - merging/inlining of code is done by the igor module - of syntax_tools. By default the functions generated - from the first asn1 spec in the .set.asn are - exported, unless a {export,[atom()]} or - {export_all,true} option are provided. The list of - atoms are names of choosen asn1 specs from the - .set.asn file. See further examples of usage below

-
+'Any Erlc Option'

You may add any option to the Erlang compiler when @@ -454,21 +438,8 @@ asn1rt:decode('H323-MESSAGES','SomeChoiceType',Bytes). any reason. Maybe you need to compile the same specs for different encoding/decoding standards. You want only one resulting module. - If it is crucial to have a minimal system. Using - {inline,OutputModule} includes all necessary run-time - functions of the asn1 application, but skips those modules not - used. - Upgrading issues: Even if you upgrade your Erlang system - you may want to continue running the old asn1 run-time - functionality. - Performance issues: If you have an asn1 system with a lot - of cross references you may gain in performance. Measurements - must be done for each case. -

You may choose either the plain multi file compilation that just - merges the chosen asn1 specs or the {inline,OutputModule} - that also includes the used asn1 run-time functionality.

-

For both cases you need to specify which asn1 specs you will +

You need to specify which asn1 specs you will compile in a module that must have the extension .set.asn. You chose name of the module and provide the names of the asn1 specs. For instance, if you have the specs @@ -482,17 +453,7 @@ File3.asn ~> erlc MyModule.set.asn

the result will be one merged module MyModule.erl with - the generated code from the three asn1 specs. But if you compile - with:

- -~> erlc +"{inline,'OutputModule'}" MyModule.set.asn -

the result will be a module OutputModule.erl that - contains all encode/decode functions for the three asn1 specs and - all used functions from the asn1 run-time modules, in this case - asn1rt_ber_bin. In the former case all encode/decode - functions are exported but in the latter only the encode/decode - functions of the first spec in the .set.asn, i.e. those - from File1.asn. + the generated code from the three asn1 specs.

diff --git a/lib/asn1/doc/src/asn1ct.xml b/lib/asn1/doc/src/asn1ct.xml index bb3c6a4f0f..7ad4d14610 100644 --- a/lib/asn1/doc/src/asn1ct.xml +++ b/lib/asn1/doc/src/asn1ct.xml @@ -65,7 +65,7 @@ Options = [Option| OldOption] Option = ber | per | uper | der | compact_bit_string | noobj | {n2n, EnumTypeName} |{outdir, Dir} | {i, IncludeDir} | - asn1config | undec_rest | {inline, OutputName} | inline | + asn1config | undec_rest | {macro_name_prefix, Prefix} | {record_name_prefix, Prefix} | verbose | warnings_as_errors OldOption = ber | per Reason = term() @@ -233,28 +233,6 @@ Binary = binary() list or a binary. Earlier versions of the compiler ignored those following bytes.

- {inline, OutputName} - -

Compiling with this option gives one output module - containing all asn1 run-time functionality. The asn1 specs - are provided in a target module Module.set.asn as described - above. The name of the - resulting module containing generated encode/decode functions - and in-lined run-time functions will be - OutputName.erl. The merging/in-lining of code is done - by the igor module of syntax_tools. By default - the functions generated from the first asn1 spec in the - .set.asn are exported, unless a - {export, [atom()]} or {export_all, true} option - are provided. The list of atoms are names of chosen asn1 - specs from the .set.asn file.

-
- inline - -

It is also possible to use the sole argument inline. - It is as {inline, OutputName}, but the output file gets the - default name of the source .set.asn file.

-
{macro_name_prefix, Prefix}

All macro names generated by the compiler are prefixed with diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl index e361654a81..0aa6c4c6a6 100644 --- a/lib/asn1/src/asn1ct.erl +++ b/lib/asn1/src/asn1ct.erl @@ -86,10 +86,14 @@ compile(File) -> compile(File,[]). compile(File, Options0) when is_list(Options0) -> - Options1 = translate_options(Options0), - Options2 = includes(File,Options1), - Includes = strip_includes(Options2), - in_process(fun() -> compile_proc(File, Includes, Options2) end). + try translate_options(Options0) of + Options1 -> + Options2 = includes(File,Options1), + Includes = strip_includes(Options2), + in_process(fun() -> compile_proc(File, Includes, Options2) end) + catch throw:Error -> + Error + end. compile_proc(File, Includes, Options) -> case input_file_type(File, Includes) of @@ -120,56 +124,13 @@ compile1(File,Options) when is_list(Options) -> Continue3 = check(Continue2,File,OutFile,Includes,EncodingRule, DbFile,Options,[]), Continue4 = generate(Continue3,OutFile,EncodingRule,Options), - Ret = compile_erl(Continue4,OutFile,Options), - case inline(is_inline(Options), - inline_output(Options,filename:rootname(File)), - lists:concat([OutFile,".erl"]),Options) of - false -> - Ret; - InlineRet -> - InlineRet - end. + compile_erl(Continue4, OutFile, Options). %%****************************************************************************%% %% functions dealing with compiling of several input files to one output file %% %%****************************************************************************%% -%%% -%% inline/4 -%% merges the resulting erlang modules with -%% the appropriate run-time modules so the resulting module contains all -%% run-time asn1 functionality. Then compiles the resulting file to beam code. -%% The merging is done by the igor module. If this function is used in older -%% versions than R10B the igor module, part of user contribution syntax_tools, -%% must be provided. It is possible to pass options for the ASN1 compiler -%% Types: -%% Name -> atom() -%% Modules -> [filename()] -%% Options -> [term()] -%% filename() -> file:filename() -inline(true,Name,Module,Options) -> - RTmodule = get_runtime_mod(Options), - IgorOptions = igorify_options(remove_asn_flags(Options)), - IgorName = list_to_atom(filename:rootname(filename:basename(Name))), -% io:format("*****~nName: ~p~nModules: ~p~nIgorOptions: ~p~n*****~n", -% [IgorName,Modules++RTmodule,IgorOptions]), - verbose("Inlining modules: ~p in ~p~n",[[Module]++RTmodule,IgorName],Options), - case catch igor:merge(IgorName,[Module]++RTmodule,[{preprocess,true},{stubs,false},{backups,false}]++IgorOptions) of - {'EXIT',{undef,Reason}} -> %% module igor first in R10B - error("Module igor in syntax_tools must be available:~n~p~n", - [Reason],Options), - {error,'no_compilation'}; - {'EXIT',Reason} -> - error("Merge by igor module failed due to ~p~n",[Reason],Options), - {error,'no_compilation'}; - _ -> -%% io:format("compiling output module: ~p~n",[generated_file(Name,IgorOptions)]), - erl_compile(generated_file(Name,IgorOptions),Options) - end; -inline(_,_,_,_) -> - false. - %% compile_set/3 merges and compiles a number of asn1 modules %% specified in a .set.asn file to one .erl file. compile_set(SetBase,Files,Options) @@ -218,15 +179,7 @@ check_set(ParseRes,SetBase,OutFile,Includes,EncRule,DbFile, asn1ct_table:delete([renamed_defs, original_imports, automatic_tags]), - Ret = compile_erl(Continue2,OutFile,Options), - case inline(is_inline(Options), - inline_output(Options,filename:rootname(OutFile)), - lists:concat([OutFile,".erl"]),Options) of - false -> - Ret; - InlineRet -> - InlineRet - end. + compile_erl(Continue2, OutFile, Options). %% merge_modules/2 -> returns a module record where the typeorval lists are merged, %% the exports lists are merged, the imports lists are merged when the @@ -1065,18 +1018,8 @@ get_rule(Options) -> ber end. -get_runtime_mod(Options) -> - RtMod1= - case get_rule(Options) of - per -> "asn1rt_per_bin_rt2ct.erl"; - ber -> ["asn1rt_ber_bin_v2.erl"]; - uper -> ["asn1rt_uper_bin.erl"] - end, - RtMod1++["asn1rt_check.erl","asn1rt.erl"]. - %% translate_options(NewOptions) -> OldOptions %% Translate the new option names to the old option name. -%% FIXME. We should rewrite all code to handle the new option names. translate_options([ber_bin|T]) -> io:format("Warning: The option 'ber_bin' is now called 'ber'.\n"), @@ -1093,6 +1036,12 @@ translate_options([nif|T]) -> translate_options([optimize|T]) -> io:format("Warning: The option 'optimize' is no longer needed.\n"), translate_options(T); +translate_options([inline|T]) -> + io:format("Warning: The option 'inline' is no longer needed.\n"), + translate_options(T); +translate_options([{inline,_}|_]) -> + io:format("ERROR: The option {inline,OutputFilename} is no longer supported.\n"), + throw({error,{unsupported_option,inline}}); translate_options([H|T]) -> [H|translate_options(T)]; translate_options([]) -> []. @@ -1130,23 +1079,6 @@ debug_on(Options) -> true end. -igorify_options(Options) -> - case lists:keysearch(outdir,1,Options) of - {value,{_,Dir}} -> - Options1 = lists:keydelete(outdir,1,Options), - [{dir,Dir}|Options1]; - _ -> - Options - end. - -generated_file(Name,Options) -> - case lists:keysearch(dir,1,Options) of - {value,{_,Dir}} -> - filename:join([Dir,filename:basename(Name)]); - _ -> - Name - end. - debug_off(_Options) -> erase(asndebug). @@ -1187,21 +1119,6 @@ option_add(Option, Options, Fun) -> strip_includes(Includes) -> [I || {i, I} <- Includes]. -is_inline(Options) -> - case lists:member(inline,Options) of - true -> true; - _ -> - lists:keymember(inline,1,Options) - end. - -inline_output(Options,Default) -> - case [X||{inline,X}<-Options] of - [OutputName] -> - OutputName; - _ -> - Default - end. - %% compile(AbsFileName, Options) %% Compile entry point for erl_compile. diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index ce15e01d32..5181ed1fce 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -1410,11 +1410,9 @@ gen_head(Erules,Mod,Hrl) -> emit({"-module('",Mod,"').",nl}), put(currmod,Mod), emit({"-compile(nowarn_unused_vars).",nl}), - case {Hrl,lists:member(inline,get(encoding_options))} of - {0,_} -> true; - {_,true} -> true; - _ -> - emit({"-include(\"",Mod,".hrl\").",nl}) + case Hrl of + 0 -> ok; + _ -> emit({"-include(\"",Mod,".hrl\").",nl}) end, emit(["-asn1_info([{vsn,'",asn1ct:vsn(),"'},",nl, " {module,'",Mod,"'},",nl, diff --git a/lib/asn1/test/Makefile b/lib/asn1/test/Makefile index 1794d6bb71..1fa495d8f1 100644 --- a/lib/asn1/test/Makefile +++ b/lib/asn1/test/Makefile @@ -102,7 +102,6 @@ MODULES= \ test_driver_load \ testSelectionTypes \ test_undecoded_rest \ - test_inline \ testTcapsystem \ testNBAPsystem \ test_compile_options \ diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 325293f35d..1a47d91634 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -71,7 +71,6 @@ groups() -> {group, [], [parse, test_driver_load, test_undecoded_rest, - test_inline, specialized_decodes, special_decode_performance, testMegaco, @@ -978,14 +977,8 @@ testSSLspecs(Config, Rule, Opts) -> ok = testSSLspecs:compile(Config, [Rule, compact_bit_string, der|Opts]), testSSLspecs:run(Rule), - - case code:which(asn1ct) of - cover_compiled -> - ok; - _ -> - ok = testSSLspecs:compile_inline(Config, Rule), - ok = testSSLspecs:run_inline(Rule) - end. + ok = testSSLspecs:compile_combined(Config, Rule), + ok = testSSLspecs:run_combined(Rule). testNortel(Config) -> test(Config, fun testNortel/3). testNortel(Config, Rule, Opts) -> @@ -1001,19 +994,6 @@ test_undecoded_rest(Config, Rule, Opts) -> _ -> test_undecoded_rest:test(undec_rest, Config) end. -test_inline(Config) -> - test(Config, fun test_inline/3, [ber]). -test_inline(Config, Rule, Opts) -> - case code:which(asn1ct) of - cover_compiled -> - {skip, "Not runnable when cover compiled"}; - _ -> - test_inline:compile(Config, Opts), - test_inline:main(Config, Rule), - test_inline:inline1(Config, Rule, Opts), - test_inline:performance2() - end. - testTcapsystem(Config) -> test(Config, fun testTcapsystem/3, [ber]). testTcapsystem(Config, Rule, Opts) -> @@ -1025,17 +1005,12 @@ testNBAPsystem(Config, Rule, Opts) -> testNBAPsystem:test(Rule, Config). test_compile_options(Config) -> - case code:which(asn1ct) of - cover_compiled -> - {skip, "Not runnable when cover compiled"}; - _ -> - ok = test_compile_options:wrong_path(Config), - ok = test_compile_options:path(Config), - ok = test_compile_options:noobj(Config), - ok = test_compile_options:record_name_prefix(Config), - ok = test_compile_options:verbose(Config), - ok = test_compile_options:warnings_as_errors(Config) - end. + ok = test_compile_options:wrong_path(Config), + ok = test_compile_options:path(Config), + ok = test_compile_options:noobj(Config), + ok = test_compile_options:record_name_prefix(Config), + ok = test_compile_options:verbose(Config), + ok = test_compile_options:warnings_as_errors(Config). testDoubleEllipses(Config) -> test(Config, fun testDoubleEllipses/3). testDoubleEllipses(Config, Rule, Opts) -> diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl index fda635d0eb..1e40fd7b9e 100644 --- a/lib/asn1/test/asn1_test_lib.erl +++ b/lib/asn1/test/asn1_test_lib.erl @@ -61,15 +61,12 @@ compile_erlang(Mod, Config, Options) -> [{i, CaseDir}, {outdir, CaseDir}|Options]). should_load(File, Options) -> - should_load(File, lists:member(abs, Options), - proplists:lookup(inline, Options)). - -should_load(_File, true, _Inline) -> - false; -should_load(_File, _Abs, {inline, Module}) when Module /= true -> - {module, Module}; -should_load(File, _Abs, _Inline) -> - {module, list_to_atom(strip_extension(filename:basename(File)))}. + case lists:member(abs, Options) of + true -> + false; + false -> + {module,list_to_atom(strip_extension(filename:basename(File)))} + end. strip_extension(File) -> strip_extension(File, filename:extension(File)). diff --git a/lib/asn1/test/testSSLspecs.erl b/lib/asn1/test/testSSLspecs.erl index 45c5da50f0..08da92243e 100644 --- a/lib/asn1/test/testSSLspecs.erl +++ b/lib/asn1/test/testSSLspecs.erl @@ -20,7 +20,7 @@ -module(testSSLspecs). --export([compile/2,run/1,compile_inline/2,run_inline/1]). +-export([compile/2,run/1,compile_combined/2,run_combined/1]). -include_lib("test_server/include/test_server.hrl"). @@ -42,15 +42,13 @@ compile(Config, Options) -> asn1_test_lib:compile_all(["PKIX1Explicit93", "PKIX1Implicit93"], Config, NewOptions). -compile_inline(Config, ber=Rule) -> +compile_combined(Config, ber=Rule) -> DataDir = ?config(data_dir, Config), CaseDir = ?config(case_dir, Config), Options = [{i, CaseDir}, {i, DataDir}, Rule, - der, compact_bit_string, asn1config, inline], - ok = remove_db_file_inline(CaseDir), - asn1_test_lib:compile("OTP-PKIX.set.asn", Config, Options); -compile_inline(_Config, _Rule) -> - ok. + der, compact_bit_string, asn1config], + ok = remove_db_files_combined(CaseDir), + asn1_test_lib:compile("OTP-PKIX.set.asn", Config, Options). remove_db_files(Dir) -> ?line ok = remove_db_file(Dir ++ "PKIX1Explicit93.asn1db"), @@ -65,7 +63,7 @@ remove_db_file(File) -> Err end. -remove_db_file_inline(Dir) -> +remove_db_files_combined(Dir) -> ?line ok = remove_db_file(Dir ++ "OTP-PKIX.asn1db"), ?line ok = remove_db_file(Dir ++ "SSL-PKIX.asn1db"), ?line ok = remove_db_file(Dir ++ "PKIXAttributeCertificate.asn1db"), @@ -74,14 +72,11 @@ remove_db_file_inline(Dir) -> ?line ok = remove_db_file(Dir ++ "PKIX1Implicit88.asn1db"). run(ber) -> - run1(1); -run(_) -> - ok. + run1(1). run1(6) -> ?line f1(6), ?line f2(6), -%% ?line transform3(ex(7)), ?line transform4(ex(7)); run1(N) -> ?line f1(N), @@ -146,12 +141,10 @@ ex(7) -> {1,2,840,113549,1,9,1}, [[19,5,111,116,112,67,65]]}. -run_inline(ber) -> +run_combined(ber) -> Cert = cert(), ?line {ok,{'CertificatePKIX1Explicit88',{Type,UnDec},_,_}} = 'OTP-PKIX':decode_TBSCert_exclusive(Cert), ?line {ok,_} = 'OTP-PKIX':decode_part(Type,UnDec), - ok; -run_inline(_) -> ok. cert() -> diff --git a/lib/asn1/test/test_compile_options.erl b/lib/asn1/test/test_compile_options.erl index b973c5fbcc..179299c78d 100644 --- a/lib/asn1/test/test_compile_options.erl +++ b/lib/asn1/test/test_compile_options.erl @@ -51,14 +51,13 @@ path(Config) -> {ok,CWD} = file:get_cwd(), ?line file:set_cwd(filename:join([DataDir,subdir])), - %%?line ok=asn1ct:compile(filename:join([DataDir,"../MyMerge.set.asn"]),[{inline,mymerge},{outdir,OutDir}]), - ?line ok=asn1ct:compile("../MyMerge.set.asn",[{inline,mymerge},{outdir,OutDir}]), + ok = asn1ct:compile("../MyMerge.set.asn",[{outdir,OutDir}]), ?line ok=outfiles_check(OutDir), ?line outfiles_remove(OutDir), file:set_cwd(filename:join([DataDir,subdir,subsubdir])), - ?line ok = asn1ct:compile('../../MyMerge.set.asn',[{inline,mymerge},{i,'..'},{outdir,OutDir}]), + ok = asn1ct:compile('../../MyMerge.set.asn',[{i,'..'},{outdir,OutDir}]), ?line ok=outfiles_check(OutDir,outfiles2()), file:set_cwd(CWD), @@ -182,11 +181,10 @@ outfiles_check(OutDir,[H|T]) -> outfiles_check(OutDir,T). outfiles1() -> - ["mymerge.erl","mymerge.beam","MyMerge.asn1db","MyMerge.beam", + ["MyMerge.asn1db","MyMerge.beam", "MyMerge.erl","MyMerge.hrl"]. outfiles2() -> - ["MyMerge.beam","mymerge.erl","MyMerge.asn1db","MyMerge.erl", - "mymerge.beam"]. + ["MyMerge.beam","MyMerge.asn1db","MyMerge.erl"]. outfiles_remove(OutDir) -> lists:foreach(fun(F)-> file:delete(filename:join([OutDir,F])) end, diff --git a/lib/asn1/test/test_inline.erl b/lib/asn1/test/test_inline.erl deleted file mode 100644 index e03ad739f9..0000000000 --- a/lib/asn1/test/test_inline.erl +++ /dev/null @@ -1,270 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2012. All Rights Reserved. -%% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% %CopyrightEnd% -%% -%% --module(test_inline). - --export([compile/2,main/2,inline1/3,performance/1,performance2/0]). --export([mvrasn_inlined_encdec/2,mvrasn_encdec/2, - mi_encdec/2,m_encdec/2]). - --include_lib("test_server/include/test_server.hrl"). --define(times, 5000). --define(times2, 50000). - -compile(Config, Options) -> - CaseDir = ?config(case_dir, Config), - asn1_test_lib:compile("Mvrasn.set.asn", Config, [{inline, mvrasn_inlined}|Options]), - asn1_test_lib:compile("Mod.set.asn", Config, [{inline, m}|Options]), - ok = remove_inlined_files(CaseDir, [filename:join([CaseDir, X])||X<-["m.erl", "m.beam"]]), - asn1_test_lib:compile("Mod.set.asn", Config, [inline|Options]), - ok = remove_inlined_files(CaseDir, []). - -inline1(Config, Rule, Opt) -> - CaseDir = ?config(case_dir, Config), - - asn1_test_lib:compile("P-Record", Config, [{inline, 'inlined_P_Record'}|Opt]), - test_inline1(), - - ok=remove_inlined_files2(CaseDir, ber), - - case Rule of - ber -> - asn1_test_lib:compile("P-Record", Config, - [ber, inline, asn1config|Opt]), - test_inline2(Rule, 'P-Record'), - remove_inlined_files3(CaseDir, Rule), - asn1_test_lib:compile("p_record.set.asn", Config, - [ber, inline, asn1config|Opt]), - test_inline2(Rule, 'p_record'), - remove_inlined_files4(CaseDir, Rule); - _ -> - ok - end. - -main(Config, _Erule) -> - Val = val(Config), - ?line {ok,Bytes}=asn1_wrapper:encode(mvrasn_inlined,'InsertSubscriberDataArg',Val), - ?line {ok,_Val2}=asn1_wrapper:decode(mvrasn_inlined,'InsertSubscriberDataArg',Bytes). - -test_inline1() -> - PRecMsg = {'PersonnelRecord',{'Name',"Sven","S","Svensson"}, - "manager",123,"20000202",{'Name',"Inga","K","Svensson"}, - asn1_DEFAULT}, - ?line {ok,Bytes}=asn1_wrapper:encode('inlined_P_Record','PersonnelRecord', - PRecMsg), - ?line {ok,_}=asn1_wrapper:decode('inlined_P_Record', - 'PersonnelRecord',Bytes). - -test_inline2(ber,Mod) -> - PRecMsg = {'PersonnelRecord',{'Name',"Sven","S","Svensson"}, - "manager",123,"20000202",{'Name',"Inga","K","Svensson"}, - asn1_DEFAULT}, - ?line {ok,Bytes} = Mod:encode('PersonnelRecord',PRecMsg), - {ok,_} = Mod:sel_dec(Bytes); -test_inline2(_,_) -> - ok. - -val(Config) -> - {ok,Val} = asn1ct:value('Mvrasn','InsertSubscriberDataArg', - [{i, ?config(case_dir, Config)}]), - Val. - -performance(Config) -> - Val = val(Config), - %% warm up - timer:tc(?MODULE,mvrasn_inlined_encdec,[2,Val]), - %% performance test - ?line {Time1,ok}=timer:tc(?MODULE,mvrasn_inlined_encdec,[?times,Val]), - %% warm up - timer:tc(?MODULE,mvrasn_encdec,[2,Val]), - %% performance test - ?line {Time2,ok}=timer:tc(?MODULE,mvrasn_encdec,[?times,Val]), - - ?line Comment = "inlined_code: "++ - integer_to_list(round(Time1/?times))++ - " micro,
original_code: "++ - integer_to_list(round(Time2/?times))++ -% " micro,~ninlined_code[inline]: "++ -% integer_to_list(round(Time3/?times))++ - " micro", - {comment,Comment}. - - -mvrasn_inlined_encdec(0,_) -> - ok; -mvrasn_inlined_encdec(N,V) -> - ?line {ok,B}=mvrasn_inlined:encode('InsertSubscriberDataArg',V), - ?line {ok,_R}=mvrasn_inlined:decode('InsertSubscriberDataArg',B), - mvrasn_inlined_encdec(N-1,V). - -mvrasn_encdec(0,_) -> - ok; -mvrasn_encdec(N,V) -> - ?line {ok,B}='Mvrasn-11-6':encode('InsertSubscriberDataArg',V), - ?line {ok,_R}='Mvrasn-11-6':decode('InsertSubscriberDataArg',B), - mvrasn_encdec(N-1,V). - -%% mvrasn_inlined_i_encdec(0,_) -> -%% ok; -%% mvrasn_inlined_i_encdec(N,V) -> -%% {ok,B}=mvrasn_inlined_i:encode('InsertSubscriberDataArg',V), -%% {ok,_R}=mvrasn_inlined_i:decode('InsertSubscriberDataArg',B), -%% mvrasn_inlined_i_encdec(N-1,V). - -performance2() -> - Val = mval(), - %% warm up - timer:tc(?MODULE,mi_encdec,[?times,Val]), - %% performance test - {Time1,_R1}=timer:tc(?MODULE,mi_encdec,[?times2,Val]), - %% warm up - timer:tc(?MODULE,m_encdec,[?times,Val]), - %% performance test - {Time2,_R2}=timer:tc(?MODULE,m_encdec,[?times2,Val]), - ?line Comment = "inlined_code: "++ - integer_to_list(round(Time1/?times2))++ - " micro,
original_code: "++ - integer_to_list(round(Time2/?times2))++ - " micro
"++ - "The inlined code was "++ - integer_to_list(round(((Time2-Time1)/Time2)*100))++ - " % faster than the original code.", - {comment,Comment}. - -mi_encdec(0,_) -> - ok; -mi_encdec(N,Val) -> - {ok,B}=m:encode('L',Val), - {ok,_R}=m:decode('L',B), -% io:format("a"), - mi_encdec(N-1,Val). - -m_encdec(0,_) -> - ok; -m_encdec(N,Val) -> - {ok,B}='Mod':encode('L',Val), - {ok,_R}='Mod':decode('L',B), - m_encdec(N-1,Val). - - --record('L', {country, region, name}). --record('OtherName', {locationName, thingName}). --record('FamilyName', {prefix, secondname}). --record('Lang', {l}). --record('Inhabitant', {name, country}). --record('Country', {name, language}). --record('PersonName', {name1, name2}). --record('LocName', {region, name}). --record('Reg', {name, inhabitants}). - - -mval() -> - 'L'(). -'L'() -> - #'L'{ - country='Co'(), - region='Reg'(), - name='Name'(othername)}. -'Co'() -> - 'Country'(). -'Country'()-> - #'Country'{name='Name'(othername), - language='Lang'()}. -'Lang'()-> - #'Lang'{l="englsh"}. -'Reg'() -> - #'Reg'{ - name='Name'(othername), - inhabitants='Inhabitants'()}. -'Inhabitants'()-> - lists:duplicate(5,'Inhabitant'()). -'Inhabitant'()-> - #'Inhabitant'{name='Name'(person), - country='Country'()}. -'Name'(person) -> - {person,'PersonName'()}; -'Name'(othername) -> - {othername,'OtherName'()}. -'PersonName'()-> - #'PersonName'{name1='FirstName'(firstname), - name2='FamilyName'()}. -'OtherName'()-> - #'OtherName'{locationName='LocName'(), - thingName='ThingName'()}. -'FirstName'(firstname)-> - {firstname,"Henry"}; -'FirstName'(nickname) -> - {nickname,"nick"}. -'FamilyName'() -> - #'FamilyName'{prefix=none, - secondname="Lloyd"}. -'ThingName'()-> - "Enkoping". -'LocName'()-> - #'LocName'{ - region=svealand, - name="Enkoping"}. - -remove_inlined_files(Dir,Files) -> - ModList=[filename:join([Dir,X])||X<-["Mod"]], - FileList=Files++ mods2files(ModList,".asn1db")++ - mods2files(ModList,".beam")++ - mods2files(ModList,".erl")++mods2files(ModList,".hrl"), - lists:foreach(fun(X) -> - io:format("X: ~p~n",[X]), - ?line ok=file:delete(X) - end,FileList), - ok. -mods2files(ModList,Extension) -> - [X++Extension||X<-ModList]. - - -remove_inlined_files2(Dir,Rule) -> - ?line ok=remove_inlined_files3(Dir,Rule), - TargetErl=filename:join([Dir,"inlined_P_Record.erl"]), - TargetBeam=filename:join([Dir,"inlined_P_Record.beam"]), - lists:foreach(fun(X) -> - ?line ok=file:delete(X) - end,[TargetErl,TargetBeam]), - ok. -remove_inlined_files3(Dir,ber) -> - Erl=filename:join([Dir,"P-Record.erl"]), - Beam=filename:join([Dir,"P-Record.beam"]), - Asn1DB=filename:join([Dir,"P-Record.asn1db"]), - Hrl=filename:join([Dir,"P-Record.hrl"]), - lists:foreach(fun(X) -> - ?line ok=file:delete(X) - end,[Erl,Beam,Asn1DB,Hrl]), - ok; -remove_inlined_files3(_,_) -> - ok. - -remove_inlined_files4(Dir,ber) -> - Erl=filename:join([Dir,"p_record.erl"]), - Beam=filename:join([Dir,"p_record.beam"]), - Asn1DB=filename:join([Dir,"p_record.asn1db"]), - Hrl=filename:join([Dir,"p_record.hrl"]), - ErlBak=filename:join([Dir,"p_record.erl.bak"]), - file:delete(ErlBak), - lists:foreach(fun(X) -> - ?line ok=file:delete(X) - end,[Erl,Beam,Asn1DB,Hrl]), - ok; -remove_inlined_files4(_,_) -> - ok. diff --git a/lib/public_key/asn1/Makefile b/lib/public_key/asn1/Makefile index f765906b3b..a4e36c7293 100644 --- a/lib/public_key/asn1/Makefile +++ b/lib/public_key/asn1/Makefile @@ -66,7 +66,7 @@ EBIN = ../ebin EXTRA_ERLC_FLAGS = ERL_COMPILE_FLAGS += $(EXTRA_ERLC_FLAGS) -ASN_FLAGS = -bber +der +compact_bit_string +noobj +asn1config +inline +ASN_FLAGS = -bber +der +compact_bit_string +noobj +asn1config # ---------------------------------------------------- # Targets -- cgit v1.2.3