Since all classes used by the application are present at compilation time and we know
that it doest not use dynamic class loading, we can use the option -smart to enable smart
linking and to enable further optimizations by the compiler:
> jamaica -compile -smart CaffeineMarkEmbeddedApp
Jamaica Builder Tool
+ CaffeineMarkEmbeddedApp.c
+ CaffeineMarkEmbeddedApp.makefile
Classfile compaction gain: 89.494606% (241514 ==> 25372)
gcc -O2 -o CaffeineMarkEmbeddedApp.o -c CaffeineMarkEmbeddedApp.c ...
gcc -o CaffeineMarkEmbeddedApp CaffeineMarkEmbeddedApp.o /home/...
strip CaffeineMarkEmbeddedApp |
The code size is reduced significantly since many methods within the application are never
called. This affects mainly the method from the standard Java classes. The result is
an executable file of around 243KB, only one sixth of the original executable that was obtained
without smart linking:
> ll CaffeineMarkEmbeddedApp
-rwxr-xr-x 1 user group 243736 May 24 08:58 CaffeineMarkEmbeddedApp
Additionally to the improved binary codesize, the performance could be enhanced as well
since the compiler was able to perform additional optimizations such as direct binding of
dynamic calls:
> ./CaffeineMarkEmbeddedApp
Sieve score = 5674 (98)
Loop score = 8960 (2017)
Logic score = 24462 (0)
String score = 4618 (708)
Float score = 3664 (185)
Method score = 9858 (166650)
Overall score = 7693 |