From ab435488ab6d90fb03a51f9c899ecaab44aaf35f Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 12 Feb 2015 11:41:06 +0100 Subject: [cover] Improve performance Add functions for cover compilation and analysis on multiple files. This allows for more parallelisation. All functions for cover compilation can now take a list of modules/files. cover:analyse/analyze and cover:analyse_to_file/analyze_to_file can be called without the Modules arguement in order to analyse all cover compiled and imported modules, or with a list of modules. Also, the number of lookups in ets tables is reduced, which has also improved the performance when analysing and resetting cover data. --- lib/tools/doc/src/cover.xml | 109 ++++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 40 deletions(-) (limited to 'lib/tools/doc') diff --git a/lib/tools/doc/src/cover.xml b/lib/tools/doc/src/cover.xml index 07ffa65e3d..914baa7977 100644 --- a/lib/tools/doc/src/cover.xml +++ b/lib/tools/doc/src/cover.xml @@ -5,7 +5,7 @@
2001 - 2013 + 2015 Ericsson AB, All Rights Reserved @@ -138,17 +138,18 @@ - compile(ModFile) -> Result - compile(ModFile, Options) -> Result - compile_module(ModFile) -> Result - compile_module(ModFile, Options) -> Result - Compile a module for Cover analysis. + compile(ModFiles) -> Result | [Result] + compile(ModFiles, Options) -> Result | [Result] + compile_module(ModFiles) -> Result | [Result] + compile_module(ModFiles, Options) -> Result | [Result] + Compile one or more modules for Cover analysis. + ModFiles = ModFile | [ModFile] ModFile = Module | File  Module = atom()  File = string() Options = [Option] -  Option = {i,Dir} | {d,Macro} | {d,Macro,Value} +  Option = {i,Dir} | {d,Macro} | {d,Macro,Value} | export_all See compile:file/2. Result = {ok,Module} | {error,File} | {error,not_main_node} @@ -165,6 +166,9 @@ returns {ok,Module}. Otherwise the function returns {error,File}. Errors and warnings are printed as they occur.

+

If a list of ModFiles is given as input, a list + of Result will be returned. The order of the returned + list is undefined.

Note that the internal database is (re-)initiated during the compilation, meaning any previously collected coverage data for the module will be lost.

@@ -194,9 +198,10 @@
- compile_beam(ModFile) -> Result - Compile a module for Cover analysis, using an existing beam. + compile_beam(ModFiles) -> Result | [Result] + Compile one or more modules for Cover analysis, using existing beam(s). + ModFiles = ModFile | [ModFile] ModFile = Module | BeamFile  Module = atom()  BeamFile = string() @@ -229,6 +234,9 @@ returned.

{error,BeamFile} is returned if the compiled code can not be loaded on the node.

+

If a list of ModFiles is given as input, a list + of Result will be returned. The order of the returned + list is undefined.

@@ -251,16 +259,21 @@ - analyse(Module) -> {ok,Answer} | {error,Error} - analyse(Module, Analysis) -> {ok,Answer} | {error,Error} - analyse(Module, Level) -> {ok,Answer} | {error,Error} - analyse(Module, Analysis, Level) -> {ok,Answer} | {error,Error} - Analyse a Cover compiled module. + analyse() -> {result,Ok,Fail} | {error,not_main_node} + analyse(Modules) -> OneResult | {result,Ok,Fail} | {error,not_main_node} + analyse(Analysis) -> {result,Ok,Fail} | {error,not_main_node} + analyse(Level) -> {result,Ok,Fail} | {error,not_main_node} + analyse(Modules, Analysis) -> OneResult | {result,Ok,Fail} | {error,not_main_node} + analyse(Modules, Level) -> OneResult | {result,Ok,Fail} | {error,not_main_node} + analyse(Analysis, Level) -> {result,Ok,Fail} | {error,not_main_node} + analyse(Modules, Analysis, Level) -> OneResult | {result,Ok,Fail} | {error,not_main_node} + Analyse one or more Cover compiled modules. - Module = atom() + Modules = Module | [Module] + Module = atom() Analysis = coverage | calls Level = line | clause | function | module - Answer = {Module,Value} | [{Item,Value}] + OneResult = {ok,{Module,Value}} | {ok,[{Item,Value}]} | {error, Error}  Item = Line | Clause | Function   Line = {M,N}   Clause = {M,F,A,C} @@ -269,49 +282,67 @@    N = A = C = integer()  Value = {Cov,NotCov} | Calls   Cov = NotCov = Calls = integer() - Error = {not_cover_compiled,Module} | not_main_node +  Error = {not_cover_compiled,Module} + Ok = [{Module,Value}] | [{Item,Value}] + Fail = [Error] -

Performs analysis of a Cover compiled module Module, as +

Performs analysis of one or more Cover compiled modules, as specified by Analysis and Level (see above), by examining the contents of the internal database.

Analysis defaults to coverage and Level defaults to function.

-

If Module is not Cover compiled, the function returns - {error,{not_cover_compiled,Module}}.

-

HINT: It is possible to issue multiple analyse_to_file commands at - the same time.

+

If Modules is an atom (one module), the return will + be OneResult, else the return will be + {result,Ok,Fail}.

+

If Modules is not given, all modules that have data + in the cover data table, are analysed. Note that this + includes both cover compiled modules and imported + modules.

+

If a given module is not Cover compiled, this is indicated + by the error reason {not_cover_compiled,Module}.

- analyse_to_file(Module) -> - analyse_to_file(Module,Options) -> - analyse_to_file(Module, OutFile) -> - analyse_to_file(Module, OutFile, Options) -> {ok,OutFile} | {error,Error} - Detailed coverage analysis of a Cover compiled module. + analyse_to_file() -> {result,Ok,Fail} | {error,not_main_node} + analyse_to_file(Modules) -> Answer | {result,Ok,Fail} | {error,not_main_node} + analyse_to_file(Options) -> {result,Ok,Fail} | {error,not_main_node} + analyse_to_file(Modules,Options) -> Answer | {result,Ok,Fail} | {error,not_main_node} + Detailed coverage analysis of one or more Cover compiled modules. + Modules = Module | [Module] Module = atom() - OutFile = string() + OutFile = OutDir = string() Options = [Option] - Option = html - Error = {not_cover_compiled,Module} | {file,File,Reason} | no_source_code_found | not_main_node + Option = html | {outfile,OutFile} | {outdir,OutDir} + Answer = {ok,OutFile} | {error,Error} + Ok = [OutFile] + Fail = [Error] + Error = {not_cover_compiled,Module} | {file,File,Reason} | {no_source_code_found,Module}  File = string()  Reason = term() -

Makes a copy OutFile of the source file for a module - Module, where it for each executable line is specified +

Makes copies of the source file for the given modules, + where it for each executable line is specified how many times it has been executed.

The output file OutFile defaults to Module.COVER.out, or Module.COVER.html if the option html was used.

-

If Module is not Cover compiled, the function returns - {error,{not_cover_compiled,Module}}.

+

If Modules is an atom (one module), the return will + be Answer, else the return will be a + list, {result,Ok,Fail}.

+

If Modules is not given, all modules that have data + in the cover data table, are analysed. Note that this + includes both cover compiled modules and imported + modules.

+

If a module is not Cover compiled, this is indicated by the + error reason {not_cover_compiled,Module}.

If the source file and/or the output file cannot be opened using file:open/2, the function returns {error,{file,File,Reason}} where File is the file name and Reason is the error reason.

-

If the module was cover compiled from the .beam +

If a module was cover compiled from the .beam file, i.e. using compile_beam/1 or compile_beam_directory/0,1, it is assumed that the source code can be found in the same directory as the @@ -322,10 +353,8 @@ joining ../src and the tail of the compiled path below a trailing src component, then the compiled path itself. - If no source code is found, - {error,no_source_code_found} is returned.

-

HINT: It is possible to issue multiple analyse_to_file commands at - the same time.

+ If no source code is found, this is indicated by the error reason + {no_source_code_found,Module}.

@@ -339,7 +368,7 @@ OutFile = string() Options = [Option] Option = html - Error = {not_cover_compiled,Module} | {file,File,Reason} | no_source_code_found | not_main_node + Error = {not_cover_compiled,Module} | {file,File,Reason} | {no_source_code_found,Module} | not_main_node  File = string()  Reason = term() -- cgit v1.2.3