[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

app[scripting] Compile time


SwikiCodeRobot @> 808
"Ensure scripting engine is loaded"
self	require: #( ScriptParser ScriptCompiler )
	in: (#(Bindings Scripting ScriptCompiler ScriptSteps) collect: [:each|
		'u8:aleReimondo/s8/library/scripting/',each,'.st.js' ])


"Show the time taken compiling some methods."
| compiler toDo count blk ms good note |
count := 300.
toDo := #().
good := [:array| array select: [:mth| (mth source includes: ${,$') not] ].
Object withAllSubclasses do: [:each|
	toDo size < count ifTrue: [
		toDo	addAll: (good value: each compiledMethods);
			addAll: (good value: each class compiledMethods)
	].
].
toDo isEmpty ifTrue: [ ^self error: 'Should not happen' ].
[toDo size < count] whileTrue: [ toDo addAll: toDo ].
[toDo size > count] whileTrue: [ toDo removeLast  ].
blk := [ toDo do: [:mth| [
		"self note: 'compiling ' ,mth."
		(compiler value: mth)
			compile: mth source
			forClass: mth classField
	] on: Error do: [:ex| self note: ' ' ,mth ,' - ' ,ex description ].
] ].
compiler := [:mth| ScriptCompiler new ].
note := 'Time taken in ' ,count ,' scripts = ' ,blk ms ,'ms.'.
compiler := [:mth| mth classField compiler ].
note := note ,'
Time taken to compile ' ,count ,' methods = ' ,blk ms ,'ms.'.
self note: note; alert: note.