[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [aspell-devel] Does Anyone Compile Aspell with -DNDEBUG?

From: Jose Da Silva
Subject: Re: [aspell-devel] Does Anyone Compile Aspell with -DNDEBUG?
Date: Sun, 1 Jun 2008 15:01:06 -0700
User-agent: KMail/1.9.7

This should shed some light on the subject using a self-contained program.
platform=linux, compiler = gcc, program=prezip.c

$ cp aspell-0.61-20071019/prog/prezip.c .
$ gcc -O2 -o prezip_asserted prezip.c
$ gcc -O2 -DNDEBUG -o prezip_notasserted prezip.c
$ gcc -O2 -g -o prezip_debugged prezip.c
$ ls -l prezip_*
-rwx------  11259 2008-06-01 14:08 prezip_asserted*
-rwx------  17643 2008-06-01 14:08 prezip_debugged*
-rwx------  11033 2008-06-01 14:08 prezip_notasserted*

The file size of the notasserted is slightly smaller, however the debugged 
version is significantly bigger.

Now looking at the code:

$ gcc -O2 -S -o prezip_asserted.asm prezip.c
$ gcc -O2 -DNDEBUG -S -o prezip_notasserted.asm prezip.c
$ gcc -O2 -g -S -o prezip_debugged.asm prezip.c

$ diff -E -b -u prezip_notasserted.asm prezip_asserted.asm 
$ diff -E -b -u prezip_asserted.asm prezip_debugged.asm 

The asserted code appears to include a test+branch, and an included 
assert_fail call plus some associated setup before the call within the 
extra 220 bytes of program code.
If you look at the debugged code, you will see a lot of added .loc lines 
which refer to lines in prezip.c
I did not find a .loc routine but believe it is an interrupt which inserts 
a value in a given location for debugging purposes plus has some branching 
and testing that can be used by a debugger for stepping through a program.

Looking at the above code, there is only an additional branch added to the 
asserted code compared to the nonasserted code, so it may only be worth 
comparing asserted to debugged program times.
Timewise comparing the debugged to the asserted program:

$ aspell dump master >wordlist.txt
$ time ./prezip_asserted -c <wordlist.txt >wordlist.cwl
0.06user 0.00system 0:00.08elapsed 84%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+132minor)pagefaults 0swaps
$ time ./prezip_debugged -c <wordlist.txt >wordlist.cwl
0.07user 0.00system 0:00.09elapsed 82%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+132minor)pagefaults 0swaps

user time increased from 0.06 to 0.07. This does not appear significant, 
except you "do" need to to take account that a big portion of the 0.06user 
time is spent reading/writing stdin/stdout which means actual time within 
the prezip program may be a small value such as 0.01. If so, then a 
difference of 0.01 to 0.02 would be considered a big increase.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]