Commit d2a09365 authored by simonmar's avatar simonmar

[project @ 2004-05-27 09:29:28 by simonmar]

Make getAllocations() return an Int64 to avoid Int overflow.
parent dc9ffb20
{-# OPTIONS -#include "Linker.h" #-} {-# OPTIONS -#include "Linker.h" #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- $Id: InteractiveUI.hs,v 1.165 2004/04/05 11:14:30 simonpj Exp $ -- $Id: InteractiveUI.hs,v 1.166 2004/05/27 09:29:29 simonmar Exp $
-- --
-- GHC Interactive User Interface -- GHC Interactive User Interface
-- --
-- (c) The GHC Team 2000 -- (c) The GHC Team 2004
-- --
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module InteractiveUI ( module InteractiveUI (
...@@ -57,6 +57,7 @@ import Control.Concurrent ...@@ -57,6 +57,7 @@ import Control.Concurrent
import Numeric import Numeric
import Data.List import Data.List
import Data.Int ( Int64 )
import System.Cmd import System.Cmd
import System.CPUTime import System.CPUTime
import System.Environment import System.Environment
...@@ -1018,18 +1019,20 @@ timeIt action ...@@ -1018,18 +1019,20 @@ timeIt action
a <- action a <- action
allocs2 <- io $ getAllocations allocs2 <- io $ getAllocations
time2 <- io $ getCPUTime time2 <- io $ getCPUTime
io $ printTimes (allocs2 - allocs1) (time2 - time1) io $ printTimes (fromIntegral (allocs2 - allocs1))
(time2 - time1)
return a return a
foreign import ccall "getAllocations" getAllocations :: IO Int foreign import ccall unsafe "getAllocations" getAllocations :: IO Int64
-- defined in ghc/rts/Stats.c
printTimes :: Int -> Integer -> IO () printTimes :: Integer -> Integer -> IO ()
printTimes allocs psecs printTimes allocs psecs
= do let secs = (fromIntegral psecs / (10^12)) :: Float = do let secs = (fromIntegral psecs / (10^12)) :: Float
secs_str = showFFloat (Just 2) secs secs_str = showFFloat (Just 2) secs
putStrLn (showSDoc ( putStrLn (showSDoc (
parens (text (secs_str "") <+> text "secs" <> comma <+> parens (text (secs_str "") <+> text "secs" <> comma <+>
int allocs <+> text "bytes"))) text (show allocs) <+> text "bytes")))
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- reverting CAFs -- reverting CAFs
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: Stats.c,v 1.46 2002/08/19 16:02:26 simonmar Exp $ * $Id: Stats.c,v 1.47 2004/05/27 09:29:28 simonmar Exp $
* *
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
* *
...@@ -821,5 +821,5 @@ statDescribeGens(void) ...@@ -821,5 +821,5 @@ statDescribeGens(void)
each compilation and expression evaluation. each compilation and expression evaluation.
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
extern HsInt getAllocations( void ) extern HsInt64 getAllocations( void )
{ return (HsInt)(total_allocated * sizeof(W_)); } { return (HsInt64)total_allocated * sizeof(W_); }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: Stats.h,v 1.17 2002/02/06 01:21:41 sof Exp $ * $Id: Stats.h,v 1.18 2004/05/27 09:29:29 simonmar Exp $
* *
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
* *
...@@ -45,7 +45,7 @@ extern double mut_user_time_during_heap_census(void); ...@@ -45,7 +45,7 @@ extern double mut_user_time_during_heap_census(void);
#endif // PROFILING #endif // PROFILING
extern void statDescribeGens( void ); extern void statDescribeGens( void );
extern HsInt getAllocations( void ); extern HsInt64 getAllocations( void );
#if defined(SMP) #if defined(SMP)
extern long int stat_getElapsedTime ( void ); extern long int stat_getElapsedTime ( void );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment