commentary
authorClaus Gittinger <cg@exept.de>
Sat, 13 Apr 1996 15:29:39 +0200
changeset 1175 7ca26065cf02
parent 1174 99712c0ef60a
child 1176 1c53fc7a69c0
commentary
SortColl.st
SortedCollection.st
--- a/SortColl.st	Sat Apr 13 14:54:14 1996 +0200
+++ b/SortColl.st	Sat Apr 13 15:29:39 1996 +0200
@@ -57,10 +57,10 @@
 
 examples
 "
-    when many individual elements are to be added, it may be
-    better to add them all unsorted & resort the collection completely.
+    when many elements are to be added, it may be better to add them 
+    all en-bloeque instead of individually.
     The reason is that for each individual #add:, the contents has to be
-    moved around, to create an empty slot for the new element.
+    shifted, to create an empty slot for the new element.
 
     timing example:
 
@@ -68,25 +68,23 @@
 
         o := SortedCollection new.
         rnd := Random new.
-        1000 timesRepeat:[
+        10000 timesRepeat:[
             o add:rnd next.
         ]  
 
-    takes 438 ms on a DS3100 (admitted: this is a very slow machine ;-)
+    takes 1365 ms on a P5 (admitted: this is a fast machine ;-)
     In contrast:
 
         |o rnd|
 
         o := OrderedCollection new.
         rnd := Random new.
-        1000 timesRepeat:[
+        10000 timesRepeat:[
             o add:rnd next.
         ].
         o := o asSortedCollection
 
-    takes 332 ms on the same machine.
-    Things become more drastic with more elements; with 10000 elements,
-    the times are: 15418 ms  vs.  4332 ms.
+    takes 383 ms on the same machine.
 
     If you already have a big sortedCollection at hand, adding multiple
     items may be better done with #addAll:, which resorts all elements, if
@@ -97,21 +95,21 @@
 
         o := OrderedCollection new.
         rnd := Random new.
-        1000 timesRepeat:[
+        10000 timesRepeat:[
             o add:rnd next.
         ].
         o := o asSortedCollection.
 
-    adding 1000 elements to it:
+    adding 1000 elements individually to it:
 
         1000 timesRepeat:[
             o add:rnd next.
         ].
 
-    takes 3121 ms 
+    takes 258 ms 
     (because the elements have to be shifted around for each added element);
 
-    while adding them with:
+    while adding them en-bloque with:
 
         c := OrderedCollection new.
         1000 timesRepeat:[
@@ -119,7 +117,7 @@
         ].
         o addAll:o
 
-    taks ms
+    takes 71 ms
 "
 ! !
 
@@ -716,6 +714,6 @@
 !SortedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SortColl.st,v 1.29 1996-04-13 12:53:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SortColl.st,v 1.30 1996-04-13 13:29:39 cg Exp $'
 ! !
 SortedCollection initialize!
--- a/SortedCollection.st	Sat Apr 13 14:54:14 1996 +0200
+++ b/SortedCollection.st	Sat Apr 13 15:29:39 1996 +0200
@@ -57,10 +57,10 @@
 
 examples
 "
-    when many individual elements are to be added, it may be
-    better to add them all unsorted & resort the collection completely.
+    when many elements are to be added, it may be better to add them 
+    all en-bloeque instead of individually.
     The reason is that for each individual #add:, the contents has to be
-    moved around, to create an empty slot for the new element.
+    shifted, to create an empty slot for the new element.
 
     timing example:
 
@@ -68,25 +68,23 @@
 
         o := SortedCollection new.
         rnd := Random new.
-        1000 timesRepeat:[
+        10000 timesRepeat:[
             o add:rnd next.
         ]  
 
-    takes 438 ms on a DS3100 (admitted: this is a very slow machine ;-)
+    takes 1365 ms on a P5 (admitted: this is a fast machine ;-)
     In contrast:
 
         |o rnd|
 
         o := OrderedCollection new.
         rnd := Random new.
-        1000 timesRepeat:[
+        10000 timesRepeat:[
             o add:rnd next.
         ].
         o := o asSortedCollection
 
-    takes 332 ms on the same machine.
-    Things become more drastic with more elements; with 10000 elements,
-    the times are: 15418 ms  vs.  4332 ms.
+    takes 383 ms on the same machine.
 
     If you already have a big sortedCollection at hand, adding multiple
     items may be better done with #addAll:, which resorts all elements, if
@@ -97,21 +95,21 @@
 
         o := OrderedCollection new.
         rnd := Random new.
-        1000 timesRepeat:[
+        10000 timesRepeat:[
             o add:rnd next.
         ].
         o := o asSortedCollection.
 
-    adding 1000 elements to it:
+    adding 1000 elements individually to it:
 
         1000 timesRepeat:[
             o add:rnd next.
         ].
 
-    takes 3121 ms 
+    takes 258 ms 
     (because the elements have to be shifted around for each added element);
 
-    while adding them with:
+    while adding them en-bloque with:
 
         c := OrderedCollection new.
         1000 timesRepeat:[
@@ -119,7 +117,7 @@
         ].
         o addAll:o
 
-    taks ms
+    takes 71 ms
 "
 ! !
 
@@ -716,6 +714,6 @@
 !SortedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SortedCollection.st,v 1.29 1996-04-13 12:53:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SortedCollection.st,v 1.30 1996-04-13 13:29:39 cg Exp $'
 ! !
 SortedCollection initialize!