The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Keywords that Squeak by

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Keywords that Squeak by Posted: Feb 16, 2007 2:33 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Keywords that Squeak by
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Looks like an older post got some attention. Stefan Matthias Aust dropped this nugget in my mail box the other day, and with permission which he's granted, I share it with you

"...In your blog entry about ruby keyword messages vs. Smalltalk keyword arguments you compared Ruby with Visualworks Smalltalk. I did a similar experiment using Squeak.

Now that I did the experiment, I thought I can also share it with you - hope you don't mind. Feel free to ignore it :)

To set a base line, this Ruby code

 500000.times { area :left => 1, :right => 2, :top => 3, :bottom = 4 }

needs about 2,9 seconds on my machine to run.

Running

Area compute: #(#left 1 #bottom 7 #right 20 #top 2) asArgs

in Squeak needs 9 seconds. Of that, 5.6 seconds are spent in #asArgs. I implemented that straight forward, I think:

asArgs
  | s d |
  s := self size.
  d := Dictionary new: s / 2.
  1 to: s by: 2 do: [:i | d at: (self at: i) put: (self at: i + 1)].
  ^d

Using Array#after: performs slightly better, 5 seconds, but keeping in mind that constructing the Dictionary needs about 6 seconds, the dictionary access variant is actually faster than the use of #after:.

I actually did the test because I wanted to explore the suggestion from the comment, using DNU and implemented #compute: as

 compute:
   ^(aDictionary atright - aDictionary atleft)
     * (aDictionary atbottom - aDictionary attop)
and
 doesNotUnderstand: aMessage
  (aMessage selector startsWith: 'at')
    ifTrue: [^self at: (aMessage selector allButFirst: 2)].
  ^super doesNotUnderstand: aMessage
This needs about 19 seconds to run. Doing the string operations might be expensive, so I came up with the following variant:
 ^(aDictionary at right - aDictionary at left)
     * (aDictionary at bottom - aDictionary at top)
and
 at
   ^Delegate for: self
and in Delegate
 doesNotUnderstand: aMessage
   ^delegatee at: aMessage selector
This needs 12 seconds to execute for 500.000 times.

The "native" variant using one keyword messages, btw, needs 0.3 seconds.

When using what you called the comma list form in Ruby, my 1.8.5 interpreter needs 0.7 seconds to execute that.

Running the same example with Python 2.4 - which has true keyword parameters - it executes in 0.8 seconds and 0.4 seconds with 4 comma separated values..."

The conclusion seems to be that while Squeak can better Ruby's hash pseudo keyword with Smalltalk keyword syntax, it can't simulate the "any order" nature of Ruby's psuedo hash keyword faster than Ruby can itself. Whereas VisualWorks was quite a bit quicker. Thanks for the results Stefan!

This of course leads me to toss the gauntlet over to Bryce Kampjes to see how much faster it will go when running Exupery.

Read: Keywords that Squeak by

Topic: When was that golden age of media? Previous Topic   Next Topic Topic: Grokking Duck Typing

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use