Just for fun

2 views
Skip to first unread message

hard wyrd

unread,
Feb 24, 2011, 2:55:18 AM2/24/11
to Open-ITLUG, Kagay-Anon Linux Users' Group (KLUG) Mailing List
Wala lang ko'y lingaw. Please don't derive any meaning out of this :) 

It's just fun looking at different languages.

PHP:

PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

<?php
echo str_repeat('hello world', 100);
?>

real 0m0.020s
user 0m0.000s
sys 0m0.020s

<?php
for($i=0; $i < 100; $i++) echo 'hello world';
?>

real 0m0.021s
user 0m0.010s
sys 0m0.010s


RUBY:

ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]

(0..100).each do |x| puts "hello world" end

real 0m0.016s
user 0m0.010s
sys 0m0.010s

LUA:

Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

for N=0,100 do
print "hello world"
end

real 0m0.003s
user 0m0.010s
sys 0m0.000s


--
-------------------------------------------------------------
"Penguin, penguin, and more penguin !"

http://www.madforubuntu.com
http://baudizm.blogsome.com

botp

unread,
Feb 24, 2011, 3:59:56 AM2/24/11
to open-...@googlegroups.com, hard wyrd, Kagay-Anon Linux Users' Group (KLUG) Mailing List
On Thu, Feb 24, 2011 at 3:55 PM, hard wyrd <hard...@gmail.com> wrote:
> (0..100).each do |x| puts "hello world" end

if you just want to repeat a process, there's fixnum#times
so, in this case, the ff would do

100.times{puts "hello, world"}

it's easy to read too.. orally..

best regards -botp

hard wyrd

unread,
Feb 24, 2011, 4:51:48 AM2/24/11
to botp, open-...@googlegroups.com, Kagay-Anon Linux Users' Group (KLUG) Mailing List
I agree. And here is the timing.

100.times{puts 'hello world'}

real 0m0.014s
user 0m0.020s
sys 0m0.000s



love it :)
Reply all
Reply to author
Forward
0 new messages