The Trunk: Chronology-Core-mt.50.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Chronology-Core-mt.50.mcz

commits-2
Marcel Taeumel uploaded a new version of Chronology-Core to project The Trunk:
http://source.squeak.org/trunk/Chronology-Core-mt.50.mcz

==================== Summary ====================

Name: Chronology-Core-mt.50
Author: mt
Time: 30 October 2019, 10:25:14.294226 am
UUID: f064aadc-0e62-174e-b97c-f70cc22a23f6
Ancestors: Chronology-Core-mt.49

Proposal to add GC pressure to #bench method.

=============== Diff against Chronology-Core-mt.49 ===============

Item was changed:
  ----- Method: BlockClosure>>benchFor: (in category '*chronology-core') -----
  benchFor: aDuration
  "See how many times I can value within the given duration.  I'll answer a meaningful description."
 
+ | startTime shouldRun count elapsedTime roundTo3Digits delay gcStart gcTime |
- | startTime shouldRun count elapsedTime  roundTo3Digits delay |
  roundTo3Digits := [:num |
  | rounded lowDigit |
  rounded := (num * 1000) rounded. "round to 1/1000"
  lowDigit := (rounded numberOfDigitsInBase: 10) - 3. "keep only first 3 digits"
  rounded := rounded roundTo:(10 raisedTo: lowDigit).
  (lowDigit >= 3 or: [rounded \\ 1000 = 0]) "display fractional part only when needed"
  ifTrue: [(rounded // 1000) asStringWithCommas]
  ifFalse: [(rounded / 1000.0) printString]].
  delay := aDuration asDelay.
  count := 0.
  shouldRun := true.
+ Smalltalk garbageCollect.
  [ delay wait. shouldRun := false ] forkAt: Processor timingPriority - 1.
  startTime := Time millisecondClockValue.
+ gcStart := (Smalltalk vmParameterAt: 8) + (Smalltalk vmParameterAt: 10).
  [ shouldRun ] whileTrue: [
  self value.
  count := count + 1 ].
  elapsedTime := Time millisecondsSince: startTime.
+ gcTime := (Smalltalk vmParameterAt: 8) + (Smalltalk vmParameterAt: 10) - gcStart.
  ^(roundTo3Digits value: count * 1000 / elapsedTime) , ' per second.', ((
  #(
  (1e-3 'seconds')
  (1 'milliseconds')
  (1e3 'microseconds')
  (1e6 'nanoseconds')
  )
  detect: [ :pair | elapsedTime * pair first >= count ]
  ifNone: [ #(1e9 'picoseconds') ])
  in: [ :pair |
  ' {1} {2} per run.' format: {
  (roundTo3Digits value: elapsedTime * pair first / count).
+ pair second } ]), (' {1} % GC time.' format: {gcTime / elapsedTime * 100 roundTo: 0.0001})!
- pair second } ])!