[aida] DNU and Stack Reification Timing Tests

Edward Stow ed.stow at gmail.com
Wed Apr 2 07:03:02 CEST 2008


Hi List

Out of interest enclosed are some simple timing tests to determine the
relative amount of time taken for:
1: A direct message to a method  (direct)
2. An indirect message call via doesNotUnderstand: redirection (indirect)
3. Locating an object via by reification of the message stack. (reification)

The following code can be filed in  and then the expression performed

EsTimingTest timedTestsRepeated: 1000*1000

The results:

direct:  1.0  (this is the base measure)
indirect: 5.7 (that is 5.7 times longer than direct)
reification: 40.1 (that is 40.1 times longer than a direct message call

Interesting -- I always knew that recreating the stack was expensive.

These results may have little significance to AIDA depending on the
frequency of usage.

I have attached and enclosed the code to run the tests.
--
Edward

=======================

'From Squeak3.9.1 of 2 March 2008 [latest update: #7075] on 2 April
2008 at 3:40:25 pm'!
Object subclass: #EsTimingTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TimingTest'!

!EsTimingTest methodsFor: 'as yet unclassified' stamp: 'ehs 4/2/2008 10:08'!
directCall
	"Do nothing"! !

!EsTimingTest methodsFor: 'as yet unclassified' stamp: 'ehs 4/2/2008 15:38'!
doesNotUnderstand: aMessage

	^self
		perform: #directCall
		withArguments: aMessage arguments
! !

!EsTimingTest methodsFor: 'as yet unclassified' stamp: 'ehs 4/2/2008 15:39'!
stackReification
	"Typically the WebApplication object is about 3 or 4 levels deep.
Simulate this with the counter"
	|context counter |

	context := thisContext.
	counter := 0.
		[context notNil] whileTrue: [
		counter := counter + 1.
		((context receiver isKindOf: WebApplication) | (counter > 3))
ifTrue: [^context receiver].
		context := context sender].
! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

EsTimingTest class
	instanceVariableNames: ''!

!EsTimingTest class methodsFor: 'as yet unclassified' stamp: 'ehs
4/2/2008 15:25'!
timedTest: aBlock repeat: anInteger
	^Time millisecondsToRun: [ anInteger timesRepeat: aBlock]
		! !

!EsTimingTest class methodsFor: 'as yet unclassified' stamp: 'ehs
4/2/2008 15:36'!
timedTestsRepeated: anInteger
	| test denominator |
	test := EsTimingTest new.
	^(OrderedCollection new
		add: (denominator := self timedTest: [ test directCall ] repeat: anInteger) ;
		add: (self timedTest: [ test unknownMethod ] repeat: anInteger) ;
		add: (self timedTest: [ test stackReification ] repeat: anInteger) ;
		yourself) asArray collect: [:each | (each / denominator) roundTo: 0.1 ]! !
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EsTimingTest.st
Type: application/octet-stream
Size: 1718 bytes
Desc: not available
Url : http://lists.aidaweb.si/pipermail/aida/attachments/20080402/4c394530/attachment.dll 


More information about the Aida mailing list