Hello World in different languages and speed

Assembler


.section .data
string:
.ascii "Hello world %d \n\0";

.section .text
.globl _start
_start:
movl %esp, %ebp
subl $4, %esp

movl $10000, %eax
movl $0, %ebx

loop:
cmpl $0, %eax
je loop_end
subl $1, %eax
pushl %eax
pushl $string
call printf
addl $4, %esp
popl %eax
jmp loop

loop_end:

movl $1, %eax

movl $0, %ebx

int $0x80

real 0m0.424s
user 0m0.004s
sys 0m0.254s

PHP



real 0m0.969s
user 0m0.034s
sys 0m0.219s
}
?>

Perl

for ($count=0; $count<10000; $count++) { print "Hello World\n"; }

real 0m0.547s
user 0m0.014s
sys 0m0.267s

Python

#!/usr/bin/python
# Filename: hello.py

for i in range(0, 10000):
print "Hello, World!"
else:
print 'The for loop is over'

real 0m0.503s
user 0m0.018s
sys 0m0.273s

Leave a Reply