Skip to content

Commit 53d0986

Browse files
Clean up a bit.
1 parent a4b7ff9 commit 53d0986

File tree

7 files changed

+15
-79
lines changed

7 files changed

+15
-79
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ cabal.sandbox.config
1212
examples/Group
1313
*.sublime-*
1414
dist-newstyle/
15+
cabal.project.local

System/Metrics.hs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ module System.Metrics
6868
, Value(..)
6969
) where
7070

71-
import Control.Applicative ((<$>))
7271
import Control.Monad (forM)
7372
import qualified Data.IntMap.Strict as IM
7473
import Data.IORef (IORef, atomicModifyIORef, newIORef, readIORef)
@@ -470,20 +469,16 @@ registerGcMetrics =
470469
#if MIN_VERSION_base(4,11,0)
471470
, ("rts.gc.par_balanced_bytes_copied", Gauge . fromIntegral . Stats.cumulative_par_balanced_copied_bytes)
472471
#if MIN_VERSION_base(4,15,0)
473-
, ("rts.gc.nm.sync_cpu_ms" , Counter . nsToMs . Stats.nonmoving_gc_sync_cpu_ns)
474-
, ("rts.gc.nm.sync_elapsed_ms" , Counter . nsToMs . Stats.nonmoving_gc_sync_elapsed_ns)
475-
, ("rts.gc.nm.sync_max_elapsed_ms" , Counter . nsToMs . Stats.nonmoving_gc_sync_max_elapsed_ns)
476-
, ("rts.gc.nm.cpu_ms" , Counter . nsToMs . Stats.nonmoving_gc_cpu_ns)
477-
, ("rts.gc.nm.elapsed_ms" , Counter . nsToMs . Stats.nonmoving_gc_elapsed_ns)
478-
, ("rts.gc.nm.max_elapsed_ms" , Counter . nsToMs . Stats.nonmoving_gc_max_elapsed_ns)
472+
, ("rts.gc.nm.sync_cpu_ms" , Counter . nsToMs . fromIntegral . Stats.nonmoving_gc_sync_cpu_ns)
473+
, ("rts.gc.nm.sync_elapsed_ms" , Counter . nsToMs . fromIntegral . Stats.nonmoving_gc_sync_elapsed_ns)
474+
, ("rts.gc.nm.sync_max_elapsed_ms" , Counter . nsToMs . fromIntegral . Stats.nonmoving_gc_sync_max_elapsed_ns)
475+
, ("rts.gc.nm.cpu_ms" , Counter . nsToMs . fromIntegral . Stats.nonmoving_gc_cpu_ns)
476+
, ("rts.gc.nm.elapsed_ms" , Counter . nsToMs . fromIntegral . Stats.nonmoving_gc_elapsed_ns)
477+
, ("rts.gc.nm.max_elapsed_ms" , Counter . nsToMs . fromIntegral . Stats.nonmoving_gc_max_elapsed_ns)
479478
# endif
480479
# endif
481480
])
482481
getRTSStats
483-
where
484-
-- | Convert nanoseconds to milliseconds.
485-
nsToMs :: Int64 -> Int64
486-
nsToMs s = round (realToFrac s / (1000000.0 :: Double))
487482
#else
488483
(M.fromList
489484
[ ("rts.gc.bytes_allocated" , Counter . Stats.bytesAllocated)

benchmarks/Counter.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ module Main where
55

66
import Control.Concurrent
77
import Control.Monad
8-
import System.Metrics.Counter
8+
import qualified System.Metrics.Counter as C
99

1010
main :: IO ()
1111
main = do
12-
counter <- new
12+
counter <- C.new
1313
locks <- replicateM n newEmptyMVar
1414
mapM_ (forkIO . work counter iters) locks
1515
mapM_ takeMVar locks
16+
fin <- C.read counter
17+
when (fin /= (n * iters)) $
18+
fail "Data.Atomic is broken!"
1619
where
1720
n = 100
1821
iters = 100000
1922

20-
work :: Counter -> Int -> MVar () -> IO ()
23+
work :: C.Counter -> Int -> MVar () -> IO ()
2124
work !_ 0 !lock = putMVar lock ()
22-
work counter i lock = inc counter >> work counter (i - 1) lock
25+
work counter i lock = C.inc counter >> work counter (i - 1) lock

cbits/atomic.c

Lines changed: 0 additions & 17 deletions
This file was deleted.

cbits/distrib.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

cbits/distrib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#endif
1212

1313
struct distrib {
14+
// 0 -> unlocked; 1 -> locked
1415
HSINTTYPE lock;
1516
HSINTTYPE count;
1617
double mean;

ekg-core.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ library
6262
includes: distrib.h
6363
install-includes: distrib.h
6464
include-dirs: cbits
65-
c-sources:
66-
cbits/atomic.c
67-
cbits/distrib.c
6865

6966
benchmark counter
7067
main-is: Counter.hs

0 commit comments

Comments
 (0)