Parcourir la source

For testing, initialize the heap in a better way

Instead of using 1, 2, 3, ..., n, and inserting the sum of two random
10-bit values (which will almost always end up at the bottom),
initialize with 100, 200, 300, ... 100*n and insert the num of two
random 8-bit values (which will be spread out more, including a good
chance of being at the top).
Ian Goldberg il y a 7 mois
Parent
commit
484b357df5
2 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 3 3
      heap.cpp
  2. 1 1
      heap.hpp

+ 3 - 3
heap.cpp

@@ -477,7 +477,7 @@ void MinHeap::init(MPCTIO tio, yield_t & yield) {
 }
 
 
-// This function simply inits a heap with values 1,2,...,n
+// This function simply inits a heap with values 100,200,...,100*n
 // We use this function only to set up our heap 
 // to do timing experiments on insert and extractmins
 void MinHeap::init(MPCTIO tio, yield_t & yield, size_t n) {
@@ -487,7 +487,7 @@ void MinHeap::init(MPCTIO tio, yield_t & yield, size_t n) {
     HeapArray.explicitonly(true);
     for (size_t j = 1; j <= n; ++j) {
         RegAS v;
-        v.ashare = j * tio.player();
+        v.ashare = (j * tio.player()) * 100;
         HeapArray[j] = v;
     }
     HeapArray.explicitonly(false);
@@ -715,7 +715,7 @@ void Heap(MPCIO & mpcio,  const PRACOptions & opts, char ** args) {
         for (size_t j = 0; j < n_inserts; ++j) {
             
             RegAS inserted_val;
-            inserted_val.randomize(10);
+            inserted_val.randomize(8);
            
             #ifdef HEAP_VERBOSE
             inserted_val.ashare = inserted_val.ashare;

+ 1 - 1
heap.hpp

@@ -24,7 +24,7 @@ public:
     // Intializes the heap array with 0x7fffffffffffff
     void init(MPCTIO tio, yield_t & yield);
     
-    // This function simply inits a heap with values 1,2,...,n
+    // This function simply inits a heap with values 100,200,...,100*n
     // We use this function only to set up our heap 
     // to do timing experiments on insert and extractmins
     void init(MPCTIO tio, yield_t & yield, size_t n);