Delphi IDE如何计算SLOC? [英] How is SLOC counted by Delphi IDE?

查看:64
本文介绍了Delphi IDE如何计算SLOC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您经常在这里看到人们说他们有X百万行代码项目.如何测量?是信息"菜单下显示的数字吗?该手册说,仅计算可编译行(因此,不带注释和空行):

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. 每个带有蓝点的行都是编译行"吗?
  2. 计数中还包括Embarcadero代码(RTL和VCL代码)和第三方库吗?
  3. (结论)当有人说一个具有100万行的Delphi程序是什么意思?

推荐答案

总行数编译器告诉您要计算单元中的行数,而不管是什么代码(还是不在那里.它甚至算空行.开始一个新项目.编译它并记下它说的行数(我的说是42).然后,在某处仅添加一个换行符,然后重新编译.它将声明还有一行代码(43).因此,似乎编译器没有考虑此数字的任何代码-仅实际的换行符.

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.

实际上,如果在主窗体的单位(新项目)以及项目的主文件中加上总行数,则总数将比编译器告诉您的总数少2(42中的40).因此,除了一个粗略的估算,我不相信这个数字的含义.

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.

诸如VCL,RTL和Indy之类的库未包括在此计数中,因为它们是预编译的.您的项目可能引用了需要编译的库或外部单元,因此也将这些内容包括在内.

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.

至于您提到它如何计数 if..then..else 块,请记住,您的5行代码可以组合为仅1行代码(带分隔符的换行符)),它仍然会编译,并且编译器只会计算1行,而不是5行.

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.

这篇关于Delphi IDE如何计算SLOC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆