static void TimeConstruction(int depth) { long tStart, tFinish; int iNumIters = NumIters(depth); Node tempTree; printf("Creating %d trees of depth %d\n", iNumIters, depth); tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { # ifndef GC tempTree = new Node0(); # else tempTree = new GC_NEW(Node0) Node0(); # endif Populate(depth, tempTree); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); printf("\tTop down construction took %d msec\n", elapsedTime(tFinish - tStart)); tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { tempTree = MakeTree(depth); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); printf("\tBottom up construction took %d msec\n", elapsedTime(tFinish - tStart)); }
static void TimeConstruction(int depth) { long tStart, tFinish; int iNumIters = NumIters(depth); Node tempTree; int i; printf ("Creating %d trees of depth %d\n", iNumIters, depth); for (i = 0; i < iNumIters; ++i) { tempTree = leaf_Node(); Populate(depth, tempTree); free_Node(tempTree); tempTree = 0; } for (i = 0; i < iNumIters; ++i) { tempTree = MakeTree(depth); free_Node(tempTree); tempTree = 0; } }
static void TimeConstruction(int depth) { long tStart, tFinish; int iNumIters = NumIters(depth); Node tempTree; cout << "Creating " << iNumIters << " trees of depth " << depth << endl; tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { # ifndef GC tempTree = new Node0(); # else tempTree = new (GC_NEW(Node0)) Node0(); # endif Populate(depth, tempTree); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); cout << "\tTop down construction took " << elapsedTime(tFinish - tStart) << " msec" << endl; tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { tempTree = MakeTree(depth); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); cout << "\tBottom up construction took " << elapsedTime(tFinish - tStart) << " msec" << endl; }