[GHC] #664: Heap profiler can report hundredths of a second as "3.100" (not "4.000")

GHC trac at galois.com
Sun Jan 22 14:56:27 EST 2006


#664: Heap profiler can report hundredths of a second as "3.100" (not "4.000")
------------------------+---------------------------------------------------
  Reporter:  guest      |          Owner:         
      Type:  bug        |         Status:  new    
  Priority:  normal     |      Milestone:         
 Component:  Profiling  |        Version:  6.4    
  Severity:  normal     |     Resolution:         
  Keywords:             |             Os:  Windows
Difficulty:  Unknown    |   Architecture:  x86    
------------------------+---------------------------------------------------
Comment (by guest):

 The problem looks to be in ghc/rts/ProfHeap.c in :
 {{{
 static void
 printSample(rtsBool beginSample, StgDouble sampleValue)
 {
     StgDouble fractionalPart, integralPart;
     fractionalPart = modf(sampleValue, &integralPart);
     fprintf(hp_file, "%s %d.%02d\n",
             (beginSample ? "BEGIN_SAMPLE" : "END_SAMPLE"),
             (int)integralPart, (int)(fractionalPart * 100 + 0.5));
 }
 }}}

 Specifically, {{{(int)(fractionalPart * 100 + 0.5)}}}.  If
 {{{fractionalPart}}} is >= 0.995, then {{{(int)(fractionalPart * 100 +
 0.5)}}} will be equal to 100 and "x.100" will be printed inj the
 "program.hp" file.

 Perhaps {{{(int)(fractionalPart * 100 + 0.5)}}} should just be
 {{{(int)(fractionalPart * 100)}}}.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/664>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list