A tinyBenchmark

One of the first things I was shown how to do in a Smalltalk Image was a tinyBenchmark. It is a particular way to get a measure of the performance of Squeak and Pharo System. I thought it would be interesting to compare the results of that between different Smalltalk Systems. I’ll take those that I have most heard of: Pharo 1.2, which uses the COG VM , Squeak 4.2, GNU Smalltalk 3.2.3, VA Smalltalk 8.0.3 and VisualWorks 7.7.1.

However, tinyBenchmarks is not available on every Smalltalk being checked. So we’ll standardize the benchmarking code in every image to be the same (in Integer class, methods tinyBenchmark, benchmark and benchFib). The experiment will be repeated 10 times with each machine to reduce error imposed by GC and OS via issuing
(1 to:10) do: [:e | Transcript show: 1 tinyBenchmarks; cr.]. . All the experiments were run in an Acer Aspire 4540 Notebook with Ubuntu Linux 10.10 32-bit. (AMD Athlon II x2 M300 (2GHz, 1MB L2 Cache), with 2GB RAM).

So… here are the results!
Bytecodes

Message Sends

My impression is that, if you are working on some non commercial effort, you should go for VisualWorks ASAP. If you want to sell sth made on Smalltalk, Pharo is really the best option right now.

I hope this comparison is useful for somebody!

UPDATE There was some discussion about this post on the official Pharo mailing list. I will work on redoing this experiments during the next days, but for now, here are some extra facts that could be useful for the analysis of the results previously shown:

  • The Pharo 1.2 benchmarks are run with the following Cog VM: ‘SimpleStackBasedCogit VMMaker-oscog.34 uuid: ec174a95-5f42-4fe0-88f0-4baff13dd3ce Oct 4 2010’. The method to get this information is Smalltalk getSystemAttribute: 1008 (Thanks Elliot!). In Squeak 4.2, this returns nil. The Smalltalk vmVersion returns ‘Squeak4.1 of 17 April 2010 [latest update: #9957]’.
  • Several people have pointed out the comparison between Squeak and Pharo as unfair, since the COG VM is mostly responsible for the performance difference, and it is also available for Squeak. However, the official distribution of Squeak does NOT still come with the COG VM, but the Squeak VM. Using that VM you get the results previously shown.

    I repeated the experiment using the same VM (the COG that came with Pharo 1.2) and the Squeak Image. With the same VM, the results are very similar in performance between Squeak and Pharo. However, Pharo has, in average, 0,14% more bytecodes and 3.89% more message sends/second.

  • Anuncios

Smalltalks 2010: A first approach

It has been quite a week. The experience of being at Smalltalks 2010 in Argentina was beyond any expectations I might have had. ¿The reason? It wasn’t only the keynotes, neither being in another country for the first time: It was because of meeting and feeling a part of the smalltalk community.

I came from Chile with several friends and classmates. Since we reached the airport, people have been taking care of us, and trying to make us feel comfortable and at home. It was very nice. We really have to thank alfonsina and the people of Caesars. It was also pretty awesome the amount of oportunities where you could talk with interesting people during the conference, from VM Hackers to researchers. I could ask questions, put my opinions over the table and mostly listen, feeling not as a foreigner but as part of the global team of the smalltalkers.

Everything began with the arrival at Caesar Smalltalk on wednesday. This company in Buenos Aires is just awesome. They work in the nicest place possible, a club with huge gardens and in nice offices. You can see at first glance that they are doing what they like, and making money. During the day, people from different parts of the world joined us at Caesars, we had lunch and after that, a very interesting talk near the swimming pool. We finally took the bus to Concepción del Uruguay.

I also met people from Cincom Smalltalk. Up to one week ago, smalltalk seemed to me just as an interesting research topic, an academic effort to program nicer. I remember talking with classmates and hearing things like “Yeah, Smalltalk, nice. But where can you work on that afterwards?” Well, there ARE a lot of interesting places to do it, and there is a need for smalltalk programmers (or at least it seems to be).

Finally, I met a different language option with future, as seen in Gilad talks: Newspeak. It removes the need for a global environment, has no mutation and you can plug just what you need in scope. So it seems as an interesting project to collabrate with and could take some of my time in the upcoming months.

The social event was just awesome. It was like a family meeting: talking, and hearing a friend playing the guitar. He seemed a little bit unreachable before the “concert”: talking of very technical stuff. Suddenly, he seemed reachable and kind of a friend. Everybody clapped after that little concert.

It was a very good experience. I met a lot of people and felt part of the Smalltalk community. I’ll have to collect some money to come back again next year!

Software de Sistemas – E/S Estándar (Streams y el Transcript)

Hola! Vamos a intentar smalltalkizar las clases presentes en la wiki de software de sistemas (https://wiki.dcc.uchile.cl/cc3301/).

Comencemos!

1. Entrada y Salida Estándar

Al menos con lo poco que conozco de Smalltalk, no hay una salida ni entrada estándar. Sin embargo, existen los “caudales” (streams), que permiten transmitir información. La manera más fácil de copiar un archivo en otro es usar:
|in out|
in:=FileStream fileNamed:'test.txt'.
out:=FileStream newFileNamed:'test2.txt'.
[in atEnd] whileFalse:[out nextPut: in next].

Si quisiéramos solo observar el elemento presente al inicio del stream utilizaríamos en vez del mensaje next el mensaje peek. Por otra parte, a la última línea le falta abstracción aún. Se puede simplificar como:

in do:[:a | out nextPutAll:a].
Podemos ver que la salida es caracter a caracter, copiando la entrada de la Closure (a) a lo más cercano a la “salida estándar”: un transcript. Basta hacer clic en el fondo de la imagen para que aparezca el menú World, luego Tools>> Transcript.


luego cambiamos la última línea por lo siguiente:
in do:[:a |
out nextPut:a.
Transcript show:a ;
cr.].

show:a muestra el caracter y el mensaje cr introduce un salto de línea (carriage return). El punto y coma se utiliza para enviar un conjunto de mensajes al mismo objeto.

Smalltalk tiene un editor por default con el mensaje edit. Para editar/ver el archivo, basta evaluar

(FileStream fileNamed:'test2.txt') edit
Los paréntesis son necesarios por el orden de evaluación de los mensajes en smalltalk:

  1. Mensajes Unarios
  2. Mensajes Binarios (ej: a+b)
  3. Mensajes Keyword (Palabra Clave): aquellos que reciben su parámetro a posteriori: (ejemplos: “fileNamed:” “ifTrue: ifFalse:”)