diff options
author | Björn Gustavsson <[email protected]> | 2013-03-07 12:33:26 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-05-31 14:52:19 +0200 |
commit | 77fde7589ae338efa15fecfb5f75ec9168fa921f (patch) | |
tree | 2812e5d376ae5511218365e3a2aaad6f9862eebb /lib | |
parent | 9d56389aa8fd0d366df7b0f666369d23cf946639 (diff) | |
download | otp-77fde7589ae338efa15fecfb5f75ec9168fa921f.tar.gz otp-77fde7589ae338efa15fecfb5f75ec9168fa921f.tar.bz2 otp-77fde7589ae338efa15fecfb5f75ec9168fa921f.zip |
Open the output file in raw mode with delayed write
This change brings down the execution time on my computer for the
entire asn1 test suite from about 340 seconds to 310 seconds.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asn1/src/asn1ct_func.erl | 21 | ||||
-rw-r--r-- | lib/asn1/src/asn1ct_gen.erl | 10 |
2 files changed, 13 insertions, 18 deletions
diff --git a/lib/asn1/src/asn1ct_func.erl b/lib/asn1/src/asn1ct_func.erl index 2d221ca1b9..262bef6862 100644 --- a/lib/asn1/src/asn1ct_func.erl +++ b/lib/asn1/src/asn1ct_func.erl @@ -37,9 +37,13 @@ need(MFA) -> cast({need,MFA}). generate(Fd) -> - req({generate,Fd}), + Used0 = req(get_used), erase(?MODULE), - ok. + Used = sofs:set(Used0, [mfa]), + Code = sofs:relation(asn1ct_rtt:code(), [{mfa,code}]), + Funcs0 = sofs:image(Code, Used), + Funcs = sofs:to_external(Funcs0), + ok = file:write(Fd, Funcs). req(Req) -> gen_server:call(get(?MODULE), Req, infinity). @@ -64,9 +68,8 @@ handle_cast({need,MFA}, #st{used=Used0}=St) -> {noreply,St} end. -handle_call({generate,Fd}, _From, #st{used=Used}=St) -> - generate(Fd, Used), - {stop,normal,ok,St}. +handle_call(get_used, _From, #st{used=Used}=St) -> + {stop,normal,gb_sets:to_list(Used),St}. terminate(_, _) -> ok. @@ -75,14 +78,6 @@ call_args([A|As], Sep) -> [Sep,A|call_args(As, ", ")]; call_args([], _) -> []. -generate(Fd, Used0) -> - Used1 = gb_sets:to_list(Used0), - Used = sofs:set(Used1, [mfa]), - Code = sofs:relation(asn1ct_rtt:code(), [{mfa,code}]), - Funcs0 = sofs:image(Code, Used), - Funcs = sofs:to_external(Funcs0), - io:put_chars(Fd, Funcs). - pull_in_deps(Ws0, Used0) -> case gb_sets:is_empty(Ws0) of true -> diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index a7a43b7426..570f41f91d 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -75,7 +75,7 @@ pgen_module(OutFile,Erules,Module, HrlGenerated = pgen_hrl(Erules,Module,TypeOrVal,Options,Indent), asn1ct_name:start(), ErlFile = lists:concat([OutFile,".erl"]), - Fid = fopen(ErlFile,[write]), + Fid = fopen(ErlFile), put(gen_file_out,Fid), asn1ct_func:start_link(), gen_head(Erules,Module,HrlGenerated), @@ -1131,7 +1131,7 @@ pgen_info() -> open_hrl(OutFile,Module) -> File = lists:concat([OutFile,".hrl"]), - Fid = fopen(File,[write]), + Fid = fopen(File), put(gen_file_out,Fid), gen_hrlhead(Module). @@ -1147,7 +1147,7 @@ demit(Term) -> % always generation emit(Term) -> - io:put_chars(get(gen_file_out), do_emit(Term)). + ok = file:write(get(gen_file_out), do_emit(Term)). do_emit({external,_M,T}) -> do_emit(T); @@ -1205,8 +1205,8 @@ call_args([A|As], Sep) -> [Sep,do_emit(A)|call_args(As, ", ")]; call_args([], _) -> []. -fopen(F, ModeList) -> - case file:open(F, ModeList) of +fopen(F) -> + case file:open(F, [write,raw,delayed_write]) of {ok, Fd} -> Fd; {error, Reason} -> |