Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any efficiency difference between using Dialyzer on Erlang beam and source code?

I collect all beam files of a project under a path like ~/erl_beam

dialyzer ~/erl_beam/*.beam --get_warnings -o static_analysis.log

It works well.

If I do it on Erlang source code:

dialyzer --get_warnings -I <Path1> --src <Path2> -o static_analysis.log

It works, too.

So why we have two ways to take static analysis on Erlang code? Is there any strength or weakness for each other?

like image 884
boeingdream Avatar asked Dec 15 '22 00:12

boeingdream


2 Answers

Very small.

Dialyzer analysis is performed on Core Erlang. This representation can be extracted either directly from a +debug_info compiled .beam file, or by compiling a .erl file. Compilation takes time, but it is of course not the most time-consuming part of the analysis.

If you have already compiled your .erl with +debug_info it is also more convenient to analyze the resulting .beam file, as you won't have to pass any compilation-related command-line options to Dialyzer.

like image 83
aronisstav Avatar answered Apr 27 '23 19:04

aronisstav


Dialyzer starts its analysis from either debug-compiled BEAM bytecode or from Erlang source code. However, several options work only for BEAM files (e.g., --build_plt).

Using BEAM files may be necessary if, for example, you don't have access to source files. If you have access to both BEAM and source files, you'll probably want to use the BEAM files as this will speed up the analysis slightly: Dialyzer will take much less time to parse its input. On the other hand, parsing takes significantly less time than the rest of the analysis, so don't expect to see much of a difference (I'd be surprised if it was more than 10%).

Apart from that, AFAIK, there's no difference in the type of analysis that Dialyzer performs, between these two cases.

like image 35
nickie Avatar answered Apr 27 '23 18:04

nickie