// array timings #include "stopwatch.h" #include <string> const int MAXIMUM = 100000; int heap_array () { Stopwatch watch; // start measuring time watch.set_title("string on heap timing"); string *pstr[MAXIMUM]; for (int i=0; i<MAXIMUM; i++) { pstr[i] = new string; } } // watch is destroyed here and reports the results int stack_array () { Stopwatch watch; watch.set_title("string on stack timing"); for (int i = 0; i < MAXIMUM; i++) { //create and destroy a local automatic string string s; } } // watch is destroyed here and reports the results int unassigned_heap () { Stopwatch watch; watch.set_title("unassigned string on heap timing"); for (int i = 0; i < MAXIMUM; i++) { // heap allocation without assignment new string; } } // watch is destroyed here and reports the results int main () { heap_array(); stack_array(); unassigned_heap(); } 1