Fibonacci in Ruby, Java and C. Ordered by CPU-seconds in a descending permutation.

July 5th, 2010

I have always known that Ruby had bad performance, but I did not think it was this bad. Somehow ugliness correlates very well with higher performance. Surely you should pick the language that fits your challenges.

real: Elapsed real time in seconds
user: Total number of CPU-seconds that the process spent in user mode.
sys: Total number of CPU-seconds that the process spent in kernel mode.

Ruby

def fib(n)
     n < 2 ? n : fib(n-1) + fib(n-2)
end
puts fib(45).to_s

time ruby fibonacci.rb

real 9m6.761s
user 1m52.923s
sys 7m4.379s

Java

public class Fib {
     public static int fib(int n){
        return n < 2 ? n : fib(n-1)+fib(n-2);
    }
    public static void main(String Args[]) {
        System.out.println("fib 45 " + fib(45));
    }
}

real 0m14.773s
user 0m13.589s
sys 0m0.073s

c

#include <stdio.h>
int fib(int n){
    return n<2 ? n : fib(n-1)+fib(n-2);
}
int main() {
    printf("Fibonacci 45 %d",fib(45));
}

Fibonacci 45 1134903170

real 0m10.948s
user 0m10.699s
sys 0m0.040s
(gcc -O3)

Java versus .net

June 30th, 2010

If god made the banana so awesome, why did he fuck up the coconut?

June 6th, 2010

Youtube defines these videos as related, it surely makes you think or not…

Kirk Cameron And Bananas

Religion is a Banana(warning: may contain pedobear)

Rejected Cartoons by: Don Hertzfeldt

Of course no one likes the facts.

mythbusted: The box has less calories and almost no nutrients.

May 31st, 2010

Adam Savage on Fora.tv

The House of Rothschild (1934)

May 28th, 2010

See it gratis here:
http://www.archive.org/details/The.House.of.Rothschild

It gives some historical background to the Napoleonic Wars – and of course financial wars…
Waterloo

I Am The Walrus

April 13th, 2010

Nr. 4 eggman har Hitler-skæg. Men hvad mon sangen handler om?

Chap er Død – Æret være dens minde

March 29th, 2010

kl 815 i dag; gav Dyrlægen Chap den sidste sprøjte – Chap havde haft en hård weekend, hvor han havde svært ved at spise.

Chap blev 16 år.
Chap

Men nu er Snowball kommet på heden, og den har fået et nyt navn ‘Snutbollen”, Og den er kommet ud af sin spiseforstyrelse.
Snutbollen

Små forskelle

February 9th, 2010

Ja! jeg er ikke druknet i en svømmepøl, eller blevet kvalt af min egen opkast – jeg er heller ikke død af en overdosis heroin – jeg har heller ikke skudt mig selv med en shutgun – og mit hjerter tikker stadig. Nu er der simpelthen en klub jeg ikke må være med i. Det er ikke nemt at blive gammel….

My girlfriend is Migrating to Ubuntu

December 26th, 2009

What you might want to setup the computer in advanced, such that it seems like a complete system. Here is some of the things for which I found to be essential

medibuntu.org

sudo wget http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list –output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get –yes -q –allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update

sudo apt-get install w32codecs libdvdcss2 googleearth non-free-codecs realplayer skype ssh flashplugin-nonfree openjdk-6-jre

Wine
https://help.ubuntu.com/community/Wine
wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/jaunty.list -O /etc/apt/sources.list.d/winehq.list

apt-get install wine

ies4linux
$ wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
$ tar -zxvf ies4linux-latest.tar.gz
$ cd ies4linux-*
./ies4linux

VirtualBox seenlessly windows
There is a nice guide here http://www.raiden.net/articles/virtualbox_in_seamless_mode/
For me I just had to edit the ‘Desktop key’ regedit to x:
else it would make a directory called ;

To help her with the technicalities I have made two shortcuts on the Desktop
one called windows start;
VBoxManage startvm thenameofthevm
and the other windows shutdown
VBoxManage controlvm thenameofthevm savestate
I Also disabled compiz(what ever makes wobbly windows by default), because it did not work well with Virtualbox seemlessly windows
windows on ubuntu
Now your girlfriend can have a stable superset of whatever she had before. One of my major hurtles with the windows platform is the impossibleness of giving support.

Vinter billeder

December 19th, 2009

Winter tree
Winter tree
Winter tree
Winter tree
Winter tree
Det nederste billede er taget kl 12:45 udenfor de andre er taget tre timer før og indendørs.