Hi Gaurav,
As said by Aliaksei, the problem is string concatenation with ,
your example takes 33 secs on a core i7 3.3Ghz (quite some ms ;) )
In Smalltalk, you handle that with streams (see Aliaksei example).
You can also add objects to all types of collections, not only strings
(Arrays etc).
You will find examples by searching references of WriteStream class (in
Nautilus, on WriteStream, right click / Analyse Class refs) or senders
of streamContents: .
Have a look at Pharo by examples chapter on streams
http://pharo.gforge.inria.fr/PBE1/PBE1ch11.html
(pdf here: http://pharobyexample.org/)
And if you want to see what is going on with some code, you can select
your code in the workspace and use the 'Profile it' option in the menu.
Alternatively, you can open the profiler tools with World
Menu/Tools/Time Profiler, paste your code in the code pane of the
profiler and run it.
A very handy tool, worth to know about it.
HTH
Regards,
Alain