As a companion piece to this test suite on Phoronix I took the following *very simple* code and ran it though GCC 4.6 (Fedora 15) and the Clang/LLVM 2.8 Suite to check performance and various optimizations being performed:
#include <stdio.h>
#include <stdlib.h>
int test_noRef(int value)
{
return value + 1;
}
int test_ref(int &value){
return value += 1;
}
int main(int argc, char *argv[]){
int t = 1;
for(int i = 0; i < 100000000; i++){
//t = test_noRef(t);
test_ref(t);
}
// final result = n loops + 1
printf("%d\n", t);
}