473,664 Members | 3,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

object file size is reduced after build

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
Dec 18 '07 #1
40 2439
>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.

Dec 19 '07 #2
On Dec 17, 11:19 pm, jayapal <jayapal...@gma il.comwrote:
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?

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.
Dec 19 '07 #3
Gordon Burditt wrote:
....
The "line of code" is an incredibly silly measure of code complexity.
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?
Dec 19 '07 #4
James Kuyper said:
Gordon Burditt wrote:
...
>The "line of code" is an incredibly silly measure of code complexity.

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.
That is unreasonable. If we want even a slight improvement on LOC, we
should be prepared to pay a little something for that improvement. Not
much, but a little. See below.
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?
LOC is basically a count of newlines. Counting semicolons would be a
marginal improvement (for C code, anyway), and is just as quick to
calculate (but, unlike LOC, it does mean you'll have to cut some code).

I would argue that a semicolon count would approximate the complexity far
more accurately than a newline count (although of course it is still
pitifully inadequate).

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 19 '07 #5
>The "line of code" is an incredibly silly measure of code complexity.
>
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?
How about 42? It's much easier to calculate, and is free of
subjective bias.


Dec 20 '07 #6
James Kuyper wrote:
Gordon Burditt wrote:
...
>The "line of code" is an incredibly silly measure of code complexity.

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?
Ah, obviously the two following snippets have widely differing
complexity:

if (i = foo(baz)) goo(flimdiddle) ;

and

i = foo(baz);
if (i)
{
goo(flimdiddle) ;
}

and the second is worth 5 times as much.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 20 '07 #7
Gordon Burditt wrote:
>>The "line of code" is an incredibly silly measure of code complexity.
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?

How about 42? It's much easier to calculate, and is free of
subjective bias.
No that does not meet constraint 3. Claiming that it does would imply
that LOC is completely and absolutely unrelated to code complexity.
Exaggerations to the contrary notwithstanding , that's simply not true.
Dec 20 '07 #8
James Kuyper said:

<snip>
I'll concede Richard Heathfield's point that the complexity of C code
can probably be measured somewhat more accurately by a count of
semicolons than by a count of newline characters, which is obviously
equally easy to calculate (but applicable only to C code). However, it's
only a small increment in accuracy. The only way to significantly
improve on LOC as a measure requires a much more complicated algorithm.

Here's a further suggestion that, IMHO, significantly improves on LOC
without requiring a great deal of complexity.

(a) pre-process the source - this saves headaches with comments and
conditional compilation and stuff;
(b) now get counting:

* for each semicolon, count 1.
* for each left parenthesis, count 1.
* for each operator, count 1.
* for each instance of 'if', count 1.
* for each instance of 'for' or 'while', count 2.
* for each instance of 'case', count 1.
* for each instance of 'continue', count 1.
* for each instance of 'break', count 1.
* for each instance of 'goto', count 5.
* for each instance of 'setjmp' or 'longjmp', count 10.

(Adjust figures to taste.)

While this is a fair bit more work to implement than "count semicolons",
it's still not too bad, and could be done in a few minutes by any
reasonably competent C programmer.

BTW if you want to know complexity density rather than absolute complexity,
divide by LOC (or perhaps by file size) at the end.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 20 '07 #9
James Kuyper <ja*********@ve rizon.netwrites :
Gordon Burditt wrote:
...
>The "line of code" is an incredibly silly measure of code complexity.

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?
Relaxing (1), I'd suggest simply counting constructs that make a
choice. Add 1 for every "if", "while" (including "do while"), "for"
and "switch". One would want to count something (1?) for every
function body so as to encourage lots of decomposition.

To get slightly more complex, I'd be inclined to add one for every
"else" that was not an "else if" and thus also for every switch case
except the first (since the switch already counts one). In such a
scheme I'd count a "while" (and probably a "for") as 2. You'd need to
take a view on "&&" and "||" which are "if"s in all but name.

I once write a program did something like this for student programs (I
wanted to encourage simple solutions) but that had a "compoundin g"
metric: each construct had a score >1 and nesting multiplied the
scores. Functions (as a syntactic form) were "free", of course, but
they carried the score of their "insides".

--
Ben.
Dec 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2737
by: Dennis Farr | last post by:
It has been suggested that rather than convert an already large flat file, with many similar rows, to XML, some type of header be attached to the file, containing some sort of meta-XML description of the rows that follow. The hope is that the result will not grow as large as a pure XML file, but still be easy to exchange. Multiple vendors would still be able to track format changes easily. The size of the flat file, without XML, is already...
16
11481
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not an object... the function is like so: function calc_total() { var x,i,base,margin,total,newmargin,newtotal; base = document.frmKitAmount.txtTotalKitValue.value; margin = document.frmKitAmount.margin.value/100;
1
3963
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of size n. There are n!/(s!(n-s)!) ways to do this. Donald E. Knuth gives several methods (algorithms) to generate all the s-combinations in . In such procedure-oriented way, each s-combination is processed while it's being generated. In some
5
3445
by: Matthias Kaeppler | last post by:
Hello, in my application, I want to print file sizes in a human readable format. However, I remember a thread here which dealt with a similar issue, and people said it'd be a bad idea to write numbers like 1024 and so on explicitly. Unfortunately I can't remember the reason. Can you elaborate on that? Thanks.
1
4659
by: Butaambala | last post by:
Hello, Using Enterprise Manager, I deleted from my database the only table that contained records (Right-Click on Table, Choose "Delete Table"). My expectation was that the LARGE .mdf file would be reduced to minimal size (at least as small as the Northwind MDF). However, it's still 4+ Gig in size!! (Northwind is 2.62 MB). This is a problem, bc I deleted the table in order to recapture hard drive space. NOTE: I already tried using...
5
445
by: Greg | last post by:
Hi, I have been unable to resolve this error message: Object Ref not set to an instance of an object. The issue is that I cannot determine which object reference is causing the problem. The line of user code that gives the error message is:
11
9569
by: Parrot | last post by:
Is there any routine I can call to reduce the size of an image file after uploading a file from a client. I am looking to reduce file sizes programmatically using C# in my web page after uploading. I know that Photoshop can do it but I need to do it dynamically in my web page. I tried doing it myself with some of the Bitmap thumbnail instructions but the resulting image is very bad. I need a file reduction routine that creates a good image...
1
3050
by: finditajr | last post by:
Hello I'm having the following problem: My main webpage calls a function stored in a .js file that creates an HTML window to display a calendar. Whenever I click on a date in that calendar, the calendar should return to the main webpage, but it cannot find the home window again. I'm getting this error: Microsoft JScript runtime error: 'self.opener.document.idFormMain.txtPeriodOfOperationEff' is null or not an object I've...
7
7293
by: zl2k | last post by:
hi, all What is the default size of a stl vector? Suppose I have integers needs to store in a vector and I know the max number of integer is, say, 1000. Will it be more efficient that I first allocate size of 1000 and then use {vector = aNumber; counter++} to populate the vector than by push_back(aNumber)? Of course I need to resize the vector after it is populated. Thanks for help. zl2k
5
519
by: jayapal | last post by:
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
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2764
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.