Chapter 7. Codesize Reduction Example

Table of Contents
Normal compilation
Smart linking and compilation
Compilation using Profiling Information
Using only the Interpreter

In this section we want to give an example on how the codesize of you Java application can be minimized while negative effects on the run-time performance are avoided. As a small example application we use Pendragon Software's embedded CaffeineMark (tm) 3.0.

Normal compilation

This application can be compiled using the Jamaica Builder. The resulting executable file is fairly large, more than 1.4MB in our example.

  > jamaica -compile CaffeineMarkEmbeddedApp
      
Jamaica Builder Tool
+ CaffeineMarkEmbeddedApp.c
+ CaffeineMarkEmbeddedApp.makefile
Classfile compaction gain: 71.4145% (241514 ==> 69038)
gcc -O2 -o CaffeineMarkEmbeddedApp.o -c CaffeineMarkEmbeddedApp.c ...
gcc -o CaffeineMarkEmbeddedApp CaffeineMarkEmbeddedApp.o /home/...
strip CaffeineMarkEmbeddedApp
    
  
  > ls -l CaffeineMarkEmbeddedApp
      -rwxr-xr-x 1 user group 1430392 May 24 08:47 CaffeineMarkEmbeddedApp
  

The performance enhanced due to compilation

  > ./CaffeineMarkEmbeddedApp
  Sieve score = 6023 (98)
Loop score = 8948 (2017)
Logic score = 24453 (0)
String score = 3891 (708)
Float score = 3861 (185)
Method score = 1611 (166650)
Overall score = 5631