How is SLOC counted by Delphi IDE?

主宰稳场 提交于 2019-12-11 02:52:41

问题


You see pretty often here people saying that they have a x million of lines of code project. How is this measured? Is this number, the number shown under 'Information' menu? The manual says that only the compilable lines are counted (so, without comments and empty lines):

Source compiled -> Displays total number of lines compiled.

But the manual doesn't explain how a piece of code as if/then/else is counted:

if B=true
then 
   for i:= 0 to 100 
    do Stuff
else ;
  1. Is every line that has a blue dot is a "compiled line"?
  2. The Embarcadero code (the RTL and VCL code) and 3rd party libraries are also included into the count?
  3. (The conclusion) What does it mean when somebody says about a Delphi program that it has 1 million lines?

回答1:


The Total lines the compiler tells you is counting the number of lines in the unit(s), regardless of what code is (or isn't) there. It even counts blank lines. Start a new project. Compile it and note the number of lines it says (mine says 42). Then, add just one line break somewhere, and compile again. It will claim there is one more line of code (43). So it does not seem the compiler takes any code into consideration for this number - only the actual line breaks.

In fact, if you add the total number of lines in the main form's unit (new project) as well as the project's main file, it will total to 2 less than what the compiler tells you (40 out of 42). So I wouldn't trust this number to mean much other than a rough estimate.

Libraries such as VCL, RTL, and Indy are not included in this count because those are pre-compiled. It is possible that your project might refer to a library or external unit which needs to be compiled, thus it will also include those into the count.

As far as your mention of how it counts if..then..else blocks, keep in mind that your 5 lines of code can be combined into just 1 line of code (stripping line breaks) and it will still compile, and the compiler will count only 1 line, not 5 lines.



来源:https://stackoverflow.com/questions/23722031/how-is-sloc-counted-by-delphi-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!