"" CLASS SpeedTester INCLUDEDEF=1 CLASSMETHODS * INSTANCEMETHODS * CLASS SimpleHanoi INCLUDEDEF=0 CLASSMETHODS BEGIN END INSTANCEMETHODS BEGIN END ! ! Object subclass: #SpeedTester instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' comment: ''! !SpeedTester class Test methods 11:00 - 01/01/98! run | results tester | results := Array new: 9. tester := self new. results at: 1 put: tester allocSpeedTest; at: 2 put: tester arrayWriteSpeedTest; at: 3 put: tester dictionaryWriteSpeedTest; at: 4 put: tester floatMathSpeedTest; at: 5 put: tester integerMathSpeedTest; at: 6 put: tester orderedCollectionIterateSpeedTest; at: 7 put: tester orderedCollectionWriteSpeedTest; at: 8 put: tester stringCompareSpeedTest; at: 9 put: (SimpleHanoi new hanoi). ^results! ! !SpeedTester class Test methods 05:37 - 01/19/98! runThreeTimes " SpeedTester runThreeTimes " | results one two three | Processor gcForceCycle ; gcForceCycle. one := self run. Processor gcForceCycle ; gcForceCycle. two := self run. Processor gcForceCycle ; gcForceCycle. three := self run. results := Array new: (one size). 1 to: results size do: [ :each | results at: each put: (((one at: each) + (two at: each) + (three at: each)) / 3.0) ]. ^results! ! !SpeedTester Test methods 05:37 - 01/19/98! allocSpeedTest "SpeedTester new allocSpeedTest" Processor gcForceCycle ; gcForceCycle. ^(Time millisecondsToRun: [ 100000 timesRepeat: [ Array new:10; new:10; new:10; new:10; new:10; new:10; new:10; new:10; new:10; new:10]. Processor gcForceCycle ; gcForceCycle ])/1000.0! ! !SpeedTester Test methods 11:00 - 01/01/98! arrayWriteSpeedTest | array junk | "SpeedTester new arrayWriteSpeedTest" junk := Object new. array := Array new: 10. ^(Time millisecondsToRun: [ 1000000 timesRepeat: [ array at: 1 put: junk; at: 2 put: junk; at: 3 put: junk; at: 4 put: junk; at: 5 put: junk; at: 6 put: junk; at: 7 put: junk; at: 8 put: junk; at: 9 put: junk; at: 10 put: junk]])/1000.0! ! !SpeedTester Test methods 07:58 - 01/01/98! dictionaryWriteSpeedTest | dict junk key1 key2 key3 key4 key5 key6 key7 key8 key9 key10 | "SpeedTester new dictionaryWriteSpeedTest" junk := Object new. key1 := Object new. key2 := Object new. key3 := Object new. key4 := Object new. key5 := Object new. key6 := Object new. key7 := Object new. key8 := Object new. key9 := Object new. key10 := Object new. ^(Time millisecondsToRun: [ 10000 timesRepeat: [ dict := IdentityDictionary new: 20. dict at: key1 put: junk; at: key2 put: junk; at: key3 put: junk; at: key4 put: junk; at: key5 put: junk; at: key6 put: junk; at: key7 put: junk; at: key8 put: junk; at: key9 put: junk; at: key10 put: junk]])/1000.0! ! !SpeedTester Test methods 11:00 - 01/01/98! floatMathSpeedTest "SpeedTester new floatMathSpeedTest" | a b c d e | a := 87.0. b := 53.0. c := -87.0. d := 42461.0. e := 5.0. ^(Time millisecondsToRun: [ 300000 timesRepeat: [ e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d]])/1000.0! ! !SpeedTester Test methods 11:00 - 01/01/98! integerMathSpeedTest "SpeedTester new integerMathSpeedTest" | a b c d e | a := 87. b := 53. c := -87. d := 42461. e := 5. ^(Time millisecondsToRun: [ 300000 timesRepeat: [ e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d. e := (e * a + b) * c + d]])/1000.0! ! !SpeedTester Test methods 11:00 - 01/01/98! orderedCollectionIterateSpeedTest | oc junk | "SpeedTester new orderedCollectionIterateSpeedTest" junk := Object new. oc := OrderedCollection new: 20. oc add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk. ^(Time millisecondsToRun: [ 100000 timesRepeat: [ oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]. oc do: [:element | ]]])/1000.0! ! !SpeedTester Test methods 07:58 - 01/01/98! orderedCollectionWriteSpeedTest | oc junk | "SpeedTester new orderedCollectionWriteSpeedTest" junk := Object new. ^(Time millisecondsToRun: [ 100000 timesRepeat: [ oc := OrderedCollection new: 20. oc add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk; add: junk]])/1000.0! ! !SpeedTester Test methods 11:00 - 01/01/98! stringCompareSpeedTest "SpeedTester new stringCompareSpeedTest" ^(Time millisecondsToRun: [ 100000 timesRepeat: [ 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings'. 'this is a test of a string compare of two long strings' = 'this is a test of a string compare of two long strings']])/1000.0! ! Compiler addCatDescription: 'Test' text: 'Test'.!