home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / smalltal / 2804 < prev    next >
Encoding:
Text File  |  1993-01-23  |  10.3 KB  |  270 lines

  1. Newsgroups: comp.lang.smalltalk
  2. Path: sparky!uunet!cs.utexas.edu!news.uta.edu!utafll!bruce
  3. From: bruce@utafll.uta.edu (Bruce Samuelson)
  4. Subject: Slopstone filein with bug corrections
  5. Message-ID: <1993Jan23.003223.11650@utagraph.uta.edu>
  6. Sender: news@utagraph.uta.edu (USENET News System)
  7. Nntp-Posting-Host: utafll.uta.edu
  8. Organization: University of Texas at Arlington
  9. Date: Sat, 23 Jan 1993 00:32:23 GMT
  10. Lines: 258
  11.  
  12. As usual, change the first few lines for Digitalk as follows. Also
  13. edit out the last few lines of my news signature at the end of the
  14. file.
  15.  
  16. Object subclass: #SlopstoneBenchmark
  17.    instanceVariableNames: 'testParams testBlocks '
  18.    classVariableNames: ''
  19.    poolDictionaries: ''!
  20.  
  21.  
  22. !SlopstoneBenchmark methods!
  23.  
  24. ------------start here---------------
  25.  
  26. 'From VisualWorks(TM), Release 1.0 of 8 October 1992 on 22 January 1993 at 9:26:32 am'!
  27.  
  28. Object subclass: #SlopstoneBenchmark
  29.    instanceVariableNames: 'testParams testBlocks '
  30.    classVariableNames: ''
  31.    poolDictionaries: ''
  32.    category: 'Public Domain-Benchmarks'!
  33.  
  34.  
  35. !SlopstoneBenchmark methodsFor: 'benchmarking'!
  36.  
  37. execute
  38.  
  39. | n nTests iters times speeds stones scale printA printB printC param
  40. count speed0 expln block time iter speed stone geoMean gm power |
  41.  
  42. n := 16000. "Number of times each test block will be evaluated."
  43. n > 16383 ifTrue: [self halt: 'Count exceeded max small int for ST/V-DOS.'].
  44.  
  45. Transcript cr; cr; show: 'Starting benchmarks with repetition count = '
  46.            , n printString , '.'.
  47.  
  48. nTests := testParams size.
  49. nTests  = testBlocks size ifFalse: [self halt: 'Inconsistent test count.'].
  50.  
  51. iters  := OrderedCollection new.
  52. times  := OrderedCollection new.
  53. speeds := OrderedCollection new.
  54. stones := OrderedCollection new.
  55. scale  := 1000. "So iterations can be reported as 1000s of iterations"
  56.  
  57. "The following blocks are restricted to two args by ST/V-DOS."
  58.  
  59. printA :=
  60.   [:iter1 :time1 |
  61.   Transcript cr.
  62.   Transcript nextPutAll: (iter1 / scale) rounded printString.
  63.   Transcript nextPutAll: '     '.
  64.   Transcript nextPutAll: time1 printString.
  65.   Transcript nextPutAll: '     '].
  66. printB :=
  67.   [:speed1 :slop1 |
  68.   Transcript nextPutAll: (speed1 / scale) rounded printString.
  69.   Transcript nextPutAll: '     '.
  70.   Transcript nextPutAll: slop1 printString.
  71.   Transcript nextPutAll: '     '].
  72. printC :=
  73.   [:expln1 |
  74.   Transcript show: expln1].
  75.  
  76. Transcript show: '
  77.  
  78. 1000s    time    1000s of
  79. itera-   sec-    iterations   slop-
  80. tions    onds    per sec      stones   explanation
  81. '.
  82.  
  83. 1 to: nTests do:
  84.   [:i |
  85.   param  := testParams at: i.
  86.   count  := param at: 1.           "repetitions of a test inside its block"
  87.   speed0 := (param at: 2) * scale. "iters/sec for a one-slopstone machine"
  88.   expln  := param at: 3.
  89.   block  := testBlocks at: i.
  90.   time   := Time millisecondsToRun: [n timesRepeat: block].
  91.   time   := (time max: 1) / 1000.0. "time is now in seconds"
  92.   iter   := count * n.
  93.   speed  := iter / time.
  94.   stone  := speed / speed0.
  95.   iters  add: iter.
  96.   times  add: time.
  97.   speeds add: speed.
  98.   stones add: stone.
  99.   printA value: iter value: time.
  100.   printB value: speed value: stone.
  101.   printC value: expln.].
  102.  
  103. geoMean :=
  104.   [:numbers |
  105.   gm := 1.
  106.   power := 1 / nTests.
  107.   numbers do: [:number | gm := gm * (number raisedTo: power)].
  108.   gm].
  109. Transcript cr.
  110. printA value: (geoMean value: iters) value: (geoMean value: times).
  111. printB value: (geoMean value: speeds) value: (geoMean value: stones).
  112. printC value: 'geometric mean'.
  113.  
  114. Transcript cr; cr; show: 'Benchmarks complete.'; cr!
  115.  
  116. readme
  117.  
  118. "INTRODUCTION
  119.  
  120. Slopstone: Smalltalk Low level OPeration Stones
  121. Portable Low Level Benchmarks for ST80 and ST/V (using 16-bit SmallIntegers)
  122. Placed in public domain January 1993  (c) Bruce Samuelson
  123. Permission is given to place this in public Smalltalk archives
  124.  
  125. Use monospaced fonts if possible to view the methods in this class.
  126.  
  127. (1) Collect garbage if supported (2) do 'SlopstoneBenchmark new runBenchmark'.
  128. Results are printed in the Transcript window.
  129. Post results for your machines to comp.lang.smalltalk or
  130. mail them to bruce@ling.uta.edu or bruce@utafll.uta.edu.
  131.  
  132. DISCUSSION
  133.    
  134. This readme method would normally be in the class comment for ST80. ST/V-DOS
  135. doesn't support class comments.
  136.  
  137. The benchmarks test strictly low level operations. They do not test higher
  138. level operations such as forming sets, sorting, or streaming, nor do they test
  139. applications. They also do not test user interface operations because of the
  140. non-portability of this area of Smalltalk and its sensitivity to the
  141. performance of the video subsystem. The tests are cpu bound. They do not
  142. access files and should not cause disk paging.
  143.  
  144. The benchmarks use loop counts of 16000 because SmallIntegers cannot exceed
  145. 16383 for ST/V-DOS. 16-bit implementions would perform worse with large loop
  146. counts. The benchmarks are also suitable for testing 32-bit versions of
  147. Smalltalk.
  148.  
  149. DEFINITION OF REFERENCE MACHINE (ONE SLOPSTONE)
  150.  
  151. The following machine is the one on which I developed these benchmarks. By
  152. convention it is defined to operate at one slopstone. It's a mid range
  153. performer for current ParcPlace versions of Smalltalk.
  154.  
  155. Hardware: Amax 486DX/33 (includes internal floating point processor and
  156. internal 8K cache), 256K external cache, 16MB RAM.
  157.  
  158. Software: ParcPlace VisualWorks 1.0, Windows 3.1, DOS 5.0 (plain vanilla
  159. setup).
  160.  
  161. COMPARISON TO XEROX DORADO
  162.  
  163. For reference, the machine runs at 649% of a Dorado on ParcPlace benchmarks
  164. for ST80 4.1. Its fast video card helps on these PPS benchmarks. I didn't run
  165. them for VisualWorks 1.0. It would be somewhat slower because there are vastly
  166. more classes.
  167.  
  168. EXAMPLE RESULTS FOR REFERENCE MACHINE
  169.  
  170. 1000s    time    1000s of
  171. itera-   sec-    iterations   slop-
  172. tions    onds    per sec      stones   explanation
  173.  
  174. 3808     0.577   6600         1.0      add integers
  175.  544     2.262    240         1.0      add floats
  176.  960     1.088    882         1.0      access strings
  177.  320     0.908    352         1.0      create objects
  178.  160     1.49     107         1.0      copy objects
  179.  480     1.129    425         1.0      perform selectors
  180.  896     1.237    724         1.0      evaluate blocks
  181.  
  182.  640     1.151    555         1.0      geometric mean"!
  183.  
  184. runBenchmark
  185.        "SlopstoneBenchmark new runBenchmark"
  186.  
  187.         self setup.
  188.         self execute!
  189.  
  190. setup
  191.  
  192. "Numbers in testParams represent the following:
  193.  
  194. Column 1   number of internal repetitions for each test inside its block
  195. Column 2   thousands of iterations per second for a one-slopstone machine."
  196.  
  197. testParams := OrderedCollection new.
  198.  
  199. testParams
  200.   add: #(238 6600 'add integers');
  201.   add: #( 34  240 'add floats');
  202.   add: #( 60  882 'access strings');
  203.   add: #( 20  352 'create objects');
  204.   add: #( 10  107 'copy objects');
  205.   add: #( 30  425 'perform selectors');
  206.   add: #( 56  724 'evaluate blocks').
  207.  
  208. testBlocks := OrderedCollection new.
  209.  
  210. "In the integer addition test, I originally had 340 internal repetitions.
  211. This caused the Digitalk compiler to blow up. The ParcPlace compiler compiled
  212. it ok but interestingly addition performed at slightly more than 50% of the
  213. performance with an internal count of 238. Perhaps something magical happens
  214. at 256."
  215.  
  216. testBlocks
  217.   add: [1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
  218.         1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
  219.         1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
  220.         1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
  221.         1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
  222.         1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
  223.         1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1];
  224.  
  225.   add: [1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+
  226.         1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0+1.0];
  227.  
  228.   add: ['a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  229.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  230.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  231.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  232.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  233.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  234.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  235.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  236.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1.
  237.         'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1. 'a' at: 1];
  238.  
  239.   add: [Object new. Object new. Object new. Object new. Object new.
  240.         Object new. Object new. Object new. Object new. Object new.
  241.         Object new. Object new. Object new. Object new. Object new.
  242.         Object new. Object new. Object new. Object new. Object new];
  243.  
  244.   add: [Object new copy copy copy copy copy copy copy copy copy copy];
  245.  
  246.   add: [0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  247.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  248.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  249.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  250.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  251.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  252.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  253.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  254.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself.
  255.         0 perform: #yourself. 0 perform: #yourself. 0 perform: #yourself];
  256.  
  257.   add: [[] value. [] value. [] value. [] value. [] value. [] value. [] value.
  258.         [] value. [] value. [] value. [] value. [] value. [] value. [] value.
  259.         [] value. [] value. [] value. [] value. [] value. [] value. [] value.
  260.         [] value. [] value. [] value. [] value. [] value. [] value. [] value.
  261.         [] value. [] value. [] value. [] value. [] value. [] value. [] value.
  262.         [] value. [] value. [] value. [] value. [] value. [] value. [] value.
  263.         [] value. [] value. [] value. [] value. [] value. [] value. [] value.
  264.         [] value. [] value. [] value. [] value. [] value. [] value. [] value]! !
  265. -- 
  266. **********************************************************
  267. * Bruce Samuelson    Department of Linguistics     *
  268. * bruce@ling.uta.edu    University of Texas at Arlington *
  269. **********************************************************
  270.