[Seaside-dev] WATagBrush>>#tag should be class side?

Esteban A. Maringolo emaringolo at gmail.com
Mon May 29 21:47:30 UTC 2017


2017-05-29 12:51 GMT-03:00 Max Leske <maxleske at gmail.com>:

>> On 29 May 2017, at 17:24, Esteban A. Maringolo <emaringolo at gmail.com> wrote:

>> Since the returned value doesn't change based on conditions of the
>> brush [1], shouldn't #tag be implemented class side and instances
>> delegate to the class by default and implement only if necessary?
>
> In general, I agree. I’m not sure what the performance costs might be, however. It’s only one message send but they add up to a lot (context creation isn’t free, unfortunately). Could you try and run a benchmark?

There seems to be a significant difference in the execution of these,
although I could bet that given the insanely fast execution of that,
it would be completely imperceivable.

Object subclass: #WATestTag.

WATestTag>>#tagClass
  ^self class tag

WATestTag>>#tagInstance
  ^'tag'

WATestTag class>>#tag
  ^'tag'


brush := WATestTag new.
{
  [ brush tagInstance ].
  [ brush tagClass ].
  [ WATestTag tag ]
 } collect: [ :each | each bench ].

 "#('88,233,008 per second' '48,986,375 per second' '83,564,833 per second')"


To get a "workable" profile sample I had to repeat the execution 10^8 times.

#tagClass
**Memory**
  old +0 bytes
  young -723,840 bytes
  used -723,840 bytes
  free +723,840 bytes

**GCs**
  full 0 totalling 0ms (0.0% uptime)
  incr 1 totalling 0ms (0.0% uptime), avg 0.0ms
  tenures 0
  root table 0 overflows

#tagInstance
**Memory**
  old +0 bytes
  young +830,776 bytes
  used +830,776 bytes
  free -830,776 bytes

**GCs**
  full 0 totalling 0ms (0.0% uptime)
  incr 0 totalling 0ms (0.0% uptime)
  tenures 0
  root table 0 overflows



What you guys think?


Esteban A. Maringolo


More information about the seaside-dev mailing list