Page 1 of 1

compiler: optimize for size?

PostPosted: 16 Jan 2011, 20:12
by MartinHerrman
The C/C++ compiler flags can be used with different optimizations (e.g. -O0, .., -O3, -Os). What is best for the EM7075?
(I know that these optimizations can result in compile errors)

Re: compiler: optimize for size?

PostPosted: 17 Jan 2011, 11:52
by Alex
Ask the guys who built the compiler :)

For me, -Os produces nicely sized and working executables though.

Re: compiler: optimize for size?

PostPosted: 17 Jan 2011, 14:00
by MartinHerrman
For me it worked out at least for unrar :-) Binary really is smaller, but I did not do any (performance) testing. I might do that soon. From your reply I understand that you do not know of any factury recommendations or benchmark results.

Re: compiler: optimize for size?

PostPosted: 17 Jan 2011, 23:48
by MartinHerrman
I just finished my last test. The results surprised me. A lot.

Test-setup:
- 700MB avi
- using winrar 3.93 32-bit for windows xp
- split the archive in 100MB parts using 'good' compression method
- running official firmware 2.0.0.13
- wd elements external harddrive, 2 gb, ext3 filesystem
- samba and rtorrent running, but no activity
- self-compiled unrar is on external harddisk
- 1 measurement per case
- wait for scan_manager to finish in between runs. It detects a new file.
- unrar e file.part1.rar

I monitor cpu usage and memory usage using 'top'. 'time' is used to measure time used for executing the command. Memusage appears to be constant during execution, but cpu-usage varies a bit. That makes the measurement less precise.

Code: Select all
Unrar version      size (bytes)   memusage (%)   cpu usage (%)   time (real, user, sys)

2.0.0.13 v3.90      345640      8.7      93-97      10m41s, 9m49s, 0m22s
default   v4.0      358288       8.9      93-97      10m12s, 9m22s, 0m22s
-Os v4.0         214432       8.8      90-95       3m50s, 3m12s, 0m21s
-O2 v4.0         234528       8.8      89-95       3m28s, 2m49s, 0m21s


This is a cpu-intensive application, which also has quite some disk i/o. To me -O2 is a clear winner. But I know that results vary depending on the type of application. On the other hand: the difference between -Os and -O2 can be neglected when you relate it to the difference between default and any of these two optimizations.