构建后,目标文件大小减小 [英] object file size is reduced after build

查看:61
本文介绍了构建后,目标文件大小减小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我们有大量代码可以解决这些问题。对于每个bug我们改变代码部分添加或删除一些代码部分。更多

正在添加代码部分,更少的是删除代码。


但问题是,在构建目标文件(更改代码)后

小于目标文件(未更改的代码)???当我们增加

代码行时,目标文件的大小应该增加但是在这里

正在降低..为什么?


这些优化问题是什么?正如我们正在做的那样

优化2.

提前致谢,

jayapal

Hi all,
We have large code on which we are solving the bugs. For every bug we
change the code part either add or delete some of the code part. More
is adding the code part and very less is deleting the code.

But the question is , after build the object file( changed code) size
is less than the object file ( unchanged code)???. As we increased
the lines of code the object file size should be increased but here it
is decresing .. why?

Is these issue with the optimization? as we are doing with
optimization 2.
Thanks in advance,
jayapal

推荐答案

>我们有大量的代码来解决这些错误。对于每个bug我们
>We have large code on which we are solving the bugs. For every bug we

>更改代码部分添加或删除一些代码部分。更多
是添加代码部分,而不是删除代码。

但问题是,在构建目标文件(更改代码)后,
小于对象文件(未更改的代码)???当我们增加代码行时,目标文件的大小应该增加但是在这里它会降低...为什么?
>change the code part either add or delete some of the code part. More
is adding the code part and very less is deleting the code.

But the question is , after build the object file( changed code) size
is less than the object file ( unchanged code)???. As we increased
the lines of code the object file size should be increased but here it
is decresing .. why?



代码行是一个令人难以置信的愚蠢的代码复杂度。

除了预处理器指令,许多编译器将接受

将所有代码放在一行上。 (虽然编译器不需要
需要接受长行,但很多都要做。)


不计算代码行数,特别是不行

管理层可以看到它。

The "line of code" is an incredibly silly measure of code complexity.
Except for preprocessor directives, many compilers will accept
putting all of the code on one line. (Although the compiler is not
required do accept long lines, many do anyway).

Do not calculate the number of lines of code, especially not where
management can see it.


12月17日晚上11点19分,jayapal< jayapal ... @ gmail .comwrote:
On Dec 17, 11:19 pm, jayapal <jayapal...@gmail.comwrote:

大家好,


我们有大量代码可以解决这些问题。对于每个bug我们改变代码部分添加或删除一些代码部分。更多

正在添加代码部分,更少的是删除代码。


但问题是,在构建目标文件(更改代码)后

小于目标文件(未更改的代码)???当我们增加

代码行时,目标文件的大小应该增加但是在这里它

正在减少..为什么?
Hi all,

We have large code on which we are solving the bugs. For every bug we
change the code part either add or delete some of the code part. More
is adding the code part and very less is deleting the code.

But the question is , after build the object file( changed code) size
is less than the object file ( unchanged code)???. As we increased
the lines of code the object file size should be increased but here it
is decresing .. why?



我可以添加两行代码,可以大大减少对象文件的大小,前提是编译器消除了无法访问的

基本块正确:


如果(0){


并且,降低:
< br $>
}


:)

也许你写的代码包含很多冗余,

编译器能够识别和消除。例如。假设你有两个

函数转换为完全相同的机器代码。

编译器可以检测到它并将它们合并到一个函数中。 (在

对象文件级别,一个函数仍然可以给出两个名字)。


这种压缩也可以在基本块级别完成,

不仅仅是一个完整的功能。假设你有一个类似的结构:


if(condition()){

S1;

} else {

S2;

}


S1和S2是不同的陈述。假设您在S1上添加了一些东西,即
,这相当于S2。这意味着无论条件采用何种方式,都执行相同的逻辑




if(condition()){

S2;

}否则{

S2;

}


编译器可识别这种情况只需将

代码重新组织为:


condition(); / *需要调用任何副作用* /

S2;


因此在S1中添加行使其与S2相同实际上导致了

缩小的程序。


I can add two lines of code that can drastically cut down the size of
an object file, provided that the compiler eliminates unreachable
basic blocks properly:

if (0) {

and, lower down:

}

:)
Maybe the code you are writing contains a lot of redundancy that the
compiler is able to recognize and eliminate. E.g. suppose you have two
functions that translate to exactly the same machine code. The
compiler can detect that and merge them into one function. (At the
object file level, one function can still be given two names).

This kind of squeezing could be done at the basic block level also,
not just one whole functions. Suppose you have a construct like:

if (condition()) {
S1;
} else {
S2;
}

S1 and S2 are different statements. Suppose you add something to S1
which makes it equivalent to S2. It means that the same logic is then
executed regardless of which way the condition goes:

if (condition()) {
S2;
} else {
S2;
}

The compiler could recognize the situation and simply reorganize the
code to:

condition(); /* necessary to call for any side effects */
S2;

And so adding lines to S1 which made it the same as S2 actually caused
the program to shrink.


Gordon Burditt写道:

....
Gordon Burditt wrote:
....

代码行是一个令人难以置信的愚蠢的代码复杂度量。
The "line of code" is an incredibly silly measure of code complexity.



好​​的。所以你会建议更换它,但需遵守以下

限制条件:

1)它必须至少像LOC一样容易计算。

2)它必须至少与LOC没有主观偏见。

3)它必须至少与LOC的代码复杂度一样准确。

从你所说的,约束3应该很容易满足;那另外两个怎么样呢?


OK. So what would you recommend to replace it, subject to the following
constraints:
1) It must be at least as easy to calculate as LOC.
2) It must be at least as free of subjective bias as LOC.
3) It must be at least as accurate a measure of code complexity as LOC.

From what you''ve said, constraint 3 should be easy to meet; how about
the other two?


这篇关于构建后,目标文件大小减小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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