Fix the profiling build
[ghc-hetmet.git] / rts / Stats.c
index ed21ec5..cbd02cd 100644 (file)
@@ -258,7 +258,8 @@ stat_startExit(void)
        PROF_VAL(RPe_tot_time + HCe_tot_time) - InitElapsedStamp;
     if (MutElapsedTime < 0) { MutElapsedTime = 0; }    /* sometimes -0.00 */
 
-    MutUserTime = user - GC_tot_time - PROF_VAL(RP_tot_time + HC_tot_time) - InitUserTime;
+    MutUserTime = user - GC_tot_time - 
+        PROF_VAL(RP_tot_time + HC_tot_time) - InitUserTime;
     if (MutUserTime < 0) { MutUserTime = 0; }
 
 #if USE_PAPI
@@ -314,15 +315,11 @@ stat_startGC(void)
        }
     }
 
-#if defined(PROFILING) || defined(DEBUG)
-    GC_start_time = getProcessCPUTime();  // needed in mut_user_time_during_GC()
-#endif
-
-    if (RtsFlags.GcFlags.giveStats != NO_GC_STATS) {
-#if !defined(PROFILING) && !defined(DEBUG)
-        GC_start_time = getProcessCPUTime();
-#endif
-       GCe_start_time = getProcessElapsedTime();
+    if (RtsFlags.GcFlags.giveStats != NO_GC_STATS
+        || RtsFlags.ProfFlags.doHeapProfile)
+        // heap profiling needs GC_tot_time
+    {
+        getProcessTimes(&GC_start_time, &GCe_start_time);
        if (RtsFlags.GcFlags.giveStats) {
            GC_start_faults = getPageFaults();
        }
@@ -346,7 +343,10 @@ void
 stat_endGC (lnat alloc, lnat live, lnat copied, lnat gen,
             lnat max_copied, lnat avg_copied, lnat slop)
 {
-    if (RtsFlags.GcFlags.giveStats != NO_GC_STATS) {
+    if (RtsFlags.GcFlags.giveStats != NO_GC_STATS ||
+        RtsFlags.ProfFlags.doHeapProfile)
+        // heap profiling needs GC_tot_time
+    {
        Ticks time, etime, gc_time, gc_etime;
        
        getProcessTimes(&time, &etime);
@@ -589,8 +589,8 @@ stat_exit(int alloc)
            statsPrintf("%16s bytes maximum slop\n", temp);
 
            statsPrintf("%16ld MB total memory in use (%ld MB lost due to fragmentation)\n\n", 
-                        mblocks_allocated * MBLOCK_SIZE_W / (1024 * 1024 / sizeof(W_)),
-                        (mblocks_allocated * MBLOCK_SIZE_W - hw_alloc_blocks * BLOCK_SIZE_W) / (1024 * 1024 / sizeof(W_)));
+                        peak_mblocks_allocated * MBLOCK_SIZE_W / (1024 * 1024 / sizeof(W_)),
+                        (peak_mblocks_allocated * BLOCKS_PER_MBLOCK * BLOCK_SIZE_W - hw_alloc_blocks * BLOCK_SIZE_W) / (1024 * 1024 / sizeof(W_)));
 
            /* Print garbage collections in each gen */
            for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
@@ -636,16 +636,20 @@ stat_exit(int alloc)
             {
                 nat i;
                 lnat sparks_created   = 0;
+                lnat sparks_dud       = 0;
                 lnat sparks_converted = 0;
-                lnat sparks_pruned    = 0;
+                lnat sparks_gcd       = 0;
+                lnat sparks_fizzled   = 0;
                 for (i = 0; i < n_capabilities; i++) {
                     sparks_created   += capabilities[i].sparks_created;
+                    sparks_dud       += capabilities[i].sparks_dud;
                     sparks_converted += capabilities[i].sparks_converted;
-                    sparks_pruned    += capabilities[i].sparks_pruned;
+                    sparks_gcd       += capabilities[i].sparks_gcd;
+                    sparks_fizzled   += capabilities[i].sparks_fizzled;
                 }
 
-                statsPrintf("  SPARKS: %ld (%ld converted, %ld pruned)\n\n",
-                            sparks_created, sparks_converted, sparks_pruned);
+                statsPrintf("  SPARKS: %ld (%ld converted, %ld dud, %ld GC'd, %ld fizzled)\n\n",
+                            sparks_created + sparks_dud, sparks_converted, sparks_dud, sparks_gcd, sparks_fizzled);
             }
 #endif
 
@@ -767,7 +771,7 @@ stat_exit(int alloc)
 void
 statDescribeGens(void)
 {
-  nat g, mut, lge;
+  nat g, mut, lge, i;
   lnat live, slop;
   lnat tot_live, tot_slop;
   bdescr *bd;
@@ -783,8 +787,8 @@ statDescribeGens(void)
   tot_slop = 0;
   for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
       mut = 0;
-      for (bd = generations[g].mut_list; bd != NULL; bd = bd->link) {
-         mut += (bd->free - bd->start) * sizeof(W_);
+      for (i = 0; i < n_capabilities; i++) {
+          mut += countOccupied(capabilities[i].mut_lists[g]);
       }
 
       gen = &generations[g];