Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speed up compiled programs using runtime information like for example JVM does it?

Java programs can outperform compiled programming languages like C in specific tasks. It is because the JVM has runtime information, and does JIT compiling when necessary (i guess).

(example: http://benchmarksgame.alioth.debian.org/u32/performance.php?test=chameneosredux)

Is there anything like this for a compiled language? (i am interested in C first of all)

After compiling the source, the developer runs it and tries to mimic typical workload. A tool gathers information about the run, and then according to this data, it recompiles again.

like image 545
jsaak Avatar asked May 31 '26 10:05

jsaak


1 Answers

gcc has -fprofile-arcs

from the manpage:

-fprofile-arcs
    Add code so that program flow arcs are instrumented. During execution the 
    program records how many times each branch and call is executed and how many 
    times it is taken or returns. When the compiled program exits it saves this 
    data to a file called auxname.gcda for each source file. The data may be 
    used for profile-directed optimizations (-fbranch-probabilities), or for 
    test coverage analysis (-ftest-coverage).
like image 142
Andreas Grapentin Avatar answered Jun 03 '26 01:06

Andreas Grapentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!