programming language runtime

Today I did a small test on the execution time of some common programming languages. For this I used implementations of ‚99 bottles of beer‘ from [[http://99-bottles-of-beer.net/]]. The test did run on my desktop machine with a AMD E-350 and plenty of ram. My machine is running ‚GNU/Linux Debian wheezy amd64‘.

openjdk-7

http://99-bottles-of-beer.net/language-java-3.html (modified: removed the sleep operations)
real 0m0.255s
user 0m0.192s
sys 0m0.048s

gcj-4.7

http://99-bottles-of-beer.net/language-java-3.html (modified: removed the sleep operations)
real 0m0.088s
user 0m0.060s
sys 0m0.024s

gcc-4.7

http://99-bottles-of-beer.net/language-c-1954.html
real 0m0.011s
user 0m0.004s
sys 0m0.004s

g++-4.7

http://99-bottles-of-beer.net/language-c++-108.html
real 0m0.020s
user 0m0.004s
sys 0m0.008s

python2.7

http://99-bottles-of-beer.net/language-python-808.html
real 0m0.068s
user 0m0.040s
sys 0m0.020s

Perl

http://99-bottles-of-beer.net/language-perl-737.html
real 0m0.022s
user 0m0.008s
sys 0m0.008s

PHP5

http://99-bottles-of-beer.net/language-php5-883.html
real 0m0.055s
user 0m0.036s
sys 0m0.016s

C♯

http://99-bottles-of-beer.net/language-csharp-2041.html (modified: removed line 40 Console.ReadLine();)
real 0m0.106s
user 0m0.076s
sys 0m0.020s

gcc optimzed code

I run a test to show how good gcc can optimze code. This is a simple program which calculates the german tax fee for a given netto value.
Even this simple code shows differences between gcc’s -O parameters.

txt@txt:~/Network/documents/coding/c$ cat mwst.c
// this program is written by txt.file

#include
#include

int main (void) {
float netto=45, mwst=0.19;
printf("Nettobetrag?> ");
//do {scanf("%f", &netto);} while ( getchar() != '\n' );
printf("Netto: %f | Brutto: %f\n", netto, netto*mwst+netto);
return EXIT_SUCCESS;
}
txt@txt:~/Network/documents/coding/c$ gcc -Wall -O2 -o O2 -march=native -pipe mwst.c
txt@txt:~/Network/documents/coding/c$ gcc -Wall -O3 -o O3 -march=native -pipe mwst.c
txt@txt:~/Network/documents/coding/c$ gcc -Wall -O1 -o O1 -march=native -pipe mwst.c
txt@txt:~/Network/documents/coding/c$ gcc -Wall -O0 -o O0 -march=native -pipe mwst.c
txt@txt:~/Network/documents/coding/c$ gcc -Wall -Os -o Os -march=native -pipe mwst.c
txt@txt:~/Network/documents/coding/c$ time ./Os
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.014s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$ time ./O0
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.014s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$ time ./O3
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.011s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$ time ./O2
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.009s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$ time ./O1
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.015s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$ time ./O0
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.026s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$ time ./Os
Nettobetrag?> Netto: 45.000000 | Brutto: 53.549999

real 0m0.017s
user 0m0.000s
sys 0m0.000s
txt@txt:~/Network/documents/coding/c$

RaspberryPi

After a friend told me yesterday that the rPi will be sold today I was very interested.
But after 2h of waiting for websites I get the feeling that I won’t get one today. farnell has sold out and rs-online has only a “register your interest” and is reported that they will sell it later this week.

bazinga

It was noted by someone on Google+ that Sheldon has no sense for sarcasm but uses it for himself. If he wants to mark something as sarcasm he says: “bazinga”.
The first time this appears in the series is Season 2 Episode 23 (S02E23). Before this episode Sheldon had really no sense of sarcasm and never understood or used it.