next up previous
Next: Dynamic Memory Allocation Up: gendrift Previous: Pointers and Arrays as

Modification and analysis

This type of simulation runs kind of slow. Let's start to use optimization flags (-O) when you compile programs. When compiler is translating the source code to object code, there are many ways to translate the same source code. Compiler analyze the source code, and it will try to make the fastest object code automatically (optimization).

gcc -O3 source.c

There are several levels of optimization (-O1 -O2 -O3). Higher number after -O means more optimization (potentially faster). By default, gcc doesn't do any optimization (equivalent to -O0, 'Oh Zero').

You can see how the optimization influence the speed by

time ./a.out


next up previous
Next: Dynamic Memory Allocation Up: gendrift Previous: Pointers and Arrays as
Naoki Takebayashi 2008-04-15