1944 methods

David T. Lewis lewis at mail.msen.com
Thu Jun 14 02:06:40 UTC 2007

On Wed, Jun 13, 2007 at 10:01:52PM +0200, Pavel Krivanek wrote:
> Hi all,
> I have played with a very simple, extremely slow but powerful shrinking 
> method:
> - take some very small image
> - create a task you want to do, for example some basic script like
> (FileStream forceNewFileNamed: 'out.txt') nextPutAll: (Compiler
> evaluate: '3+4') asString; close.
> SmalltalkImage current snapshot: true andQuit: false.
> - define the correct outputs (the file out.txt includes the text '7')
> - create a control image (with OSProcess) that takes the small image
> and starts to remove method by method and tests if the resultant image
> is not broken and returns correct outputs ;-)
> - the result is an image with the minimal possible count of methods
> for this task

Hi Pavel,

I think I can help with the "extremely slow" part. Try making the test
images (the ones started by the control image) headless, and do all the
I/O through an OS pipe rather than with files. For example:

  | pipe testBlock c |
  pipe := OSPipe new.
  testBlock := [(Compiler evaluate: '3 + 4') asString = '7'
  					ifTrue: [pipe nextPut: $Y]
  					ifFalse: [pipe nextPut: $N].
  				pipe flush].
  [10 timesRepeat:
  	["remove a method here then run the remote test"
  	UnixProcess forkHeadlessSqueakAndDoThenQuit: testBlock.
  	[(c := pipe next) isNil] whileTrue: [].
  	(c == $Y)
  		ifTrue: [Transcript show: 'the remote test succeeded'; cr]
  		ifFalse: [self error: 'the remote test failed, need to undo the last change']]] ensure: [pipe close].


More information about the Squeak-dev mailing list