Comparison QB64 compiled with gcc optimizations and without
#67
I saw in a post this sentence:

-Os enables all -O2 optimizations except those that often increase code size

by curiosity i compiled a program with this option, the executable has a size of about 1.3 mo while with the -O3 optimization it's about 1.9 mo. surprising, 600 k more. in addition the compiling time is much faster. so i decided to make a comparison test with the old data, here is the result :

simple code using pset
2.3x seconds : program compiled with qb64 v0.5.0 -O3
2.1x seconds : program compiled with qb64 v3.0.0 -O3
2.6x seconds : program compiled with qb64 v3.1.0 -Os
3.5x seconds : program compiled with qb64 v0.5.0 original

Fractal Tree : I got this code from the site rosettacode.
2.9x seconds : program compiled with qb64 v0.5.0 -O3
3.0x seconds : program compiled with qb64 v3.0.0 -O3
3.4x seconds : program compiled with qb64 v3.1.0 -Os
6.1x seconds : program compiled with qb64 v0.5.0 original

Bucketsort : I got this code from the site rosettacode.
1.1x seconds : program compiled with qb64 v0.5.0 -O3
1.0x seconds : program compiled with qb64 v3.0.0 -O3
1.0x seconds : program compiled with qb64 v3.1.0 -Os
3.4x seconds : program compiled with qb64 v0.5.0 original

sorting algorithm QuickSort.
3.0x seconds : program compiled with qb64 v0.5.0 -O3
3.0x seconds : program compiled with qb64 v3.0.0 -O3
3.2x seconds : program compiled with qb64 v3.1.0 -Os
4.6x seconds : program compiled with qb64 v0.5.0 original

Alien Trees Reflection - Plasma Mod.
5.3x seconds : program compiled with qb64 v0.5.0 -O3
5.4x seconds : program compiled with qb64 v3.0.0 -O3
6.7x seconds : program compiled with qb64 v3.1.0 -Os
9.2x seconds : program compiled with qb64 v0.5.0 original

Nbody
16.9x seconds : program compiled with qb64 v0.5.0 -O3
16.5x seconds : program compiled with qb64 v3.0.0 -O3
23.8x seconds : program compiled with qb64 v3.1.0 -Os
68.0x seconds : program compiled with qb64 v0.5.0 original

Picture unroller
1.3x seconds : program compiled with qb64 v0.5.0 -O3
1.1x seconds : program compiled with qb64 v3.0.0 -O3
1.8x seconds : program compiled with qb64 v3.1.0 -Os
2.5x seconds : program compiled with qb64 v0.5.0 original

New screen - How ?. Found in the old forum.
1.4x seconds : program compiled with qb64 v0.5.0 -O3
1.1x seconds : program compiled with qb64 v3.0.0 -O3
1.9x seconds : program compiled with qb64 v3.1.0 -Os
2.3x seconds : program compiled with qb64 v0.5.0 original

opens a text file of about 4 mo to read it line by line three times in a row with the use of Left$ InStr
6.5x seconds : program compiled with qb64 v0.5.0 -O3
6.3x seconds : program compiled with qb64 v3.0.0 -O3
6.7x seconds : program compiled with qb64 v3.1.0 -Os
7.2x seconds : program compiled with qb64 v0.5.0 original

a very simple code that opens a text file of about 4 mo to read it line by line and copy it to a new file.
3.0x seconds : program compiled with qb64 v0.5.0 -O3
2.7x seconds : program compiled with qb64 v3.0.0 -O3
2.9x seconds : program compiled with qb64 v3.1.0 -Os
3.0x seconds : program compiled with qb64 v0.5.0 original

here is another very simple code that copies a test file of about 4 mo to an array and copies the data randomly to another array.

program compiled with qb64 v0.5.0 -O3
4.4x seconds : Read file and copy to table
7.1x seconds : Copy data randomly into another table.

program compiled with qb64 v3.0.0 -O3
4.6x seconds : Read file and copy to table
8.3x seconds : Copy data randomly into another table.

program compiled with qb64 v3.1.0 -Os
4.9x seconds : Read file and copy to table
8.3x seconds : Copy data randomly into another table.

program compiled with qb64 v0.5.0 original
5.9x seconds : Read file and copy to table
27.4x seconds : Copy data randomly into another table.

found a code in the old forum
13.2x seconds : program compiled with qb64 v0.5.0 -O3
10.8x seconds : program compiled with qb64 v3.0.0 -O3
10.1x seconds : program compiled with qb64 v3.1.0 -Os
26.2x seconds : program compiled with qb64 v0.5.0 original

CRC-32 : I got this code from the site rosettacode.
6.7x seconds : program compiled with qb64 v0.5.0 -O3
6.9x seconds : program compiled with qb64 v3.0.0 -O3
10.1x seconds : program compiled with qb64 v3.1.0 -Os
17.6x seconds : program compiled with qb64 v0.5.0 original

_Deflate (compression) and _Inflate (decompression) functions.

program compiled with qb64 v0.5.0 -O3 :
Function _Deflate : 10.1x seconds
Function _Inflate : 1.2x seconds

program compiled with qb64 v3.0.0 -O3 :
Function _Deflate : 9.5x
Function _Inflate : 1.2x

program compiled with qb64 v3.1.0 -Os :
Function _Deflate : 9.5x
Function _Inflate : 1.2x

program compiled with qb64 v0.5.0 original :
Function _Deflate : 10.1x seconds
Function _Inflate : 1.2x seconds

In conclusion : programs compiled with -O3 are still faster but not by much. compile times are longer and the size of the generated executables is much larger. using the -Os option seems to be a good compromise between speed gain and optimization of the program size. the compile time is also an important criterion. after these results, i recompiled the whole qb64 in -Os. the size of the executable is about 5.5 MB instead of 7.5 MB with -O3. finally i decided to adopt the -Os option, it's mainly the gains in compile time and size of the generated programs that convinced me.
Reply


Messages In This Thread
RE: Comparison QB64 compiled with Ofast and without - by Coolman - 09-06-2022, 01:51 PM



Users browsing this thread: 29 Guest(s)