timeplot 0.1.7 → 0.1.8
raw patch · 2 files changed
+22/−4 lines, 2 files
Files
- Tools/TimePlot.hs +21/−3
- timeplot.cabal +1/−1
Tools/TimePlot.hs view
@@ -42,15 +42,25 @@ class HasDelta t where type Delta t :: * add :: Delta t -> t -> t+ sub :: t -> t -> Delta t+ -- the 't' is a dummy argument here, just to aid type checking + -- (since given just a Delta t, the compiler won't be able to + -- figure out which 't' we're speaking of)+ toSeconds :: Delta t -> t -> Double instance HasDelta Double where type Delta Double = Double add d t = t + d+ sub t2 t1 = t2 - t1+ toSeconds d _ = d instance HasDelta LocalTime where type Delta LocalTime = NominalDiffTime add d t = utcToLocalTime utc (addUTCTime d (localTimeToUTC utc t))+ sub t2 t1 = diffUTCTime (localTimeToUTC utc t2) (localTimeToUTC utc t1)+ toSeconds d _ = fromIntegral (truncate (1000000*d)) / 1000000 + instance Read NominalDiffTime where readsPrec n s = [(fromIntegral i, s') | (i,s') <- readsPrec n s] @@ -61,6 +71,7 @@ instance TimeAxis LocalTime data (TimeAxis t) => ChartKind t = KindEvent+ | KindDuration { subKind :: ChartKind t } | KindHistogram { binSize :: Delta t } | KindQuantile { binSize :: Delta t, quantiles :: [Double] } | KindBinFreq { binSize :: Delta t, delims :: [Double] }@@ -128,6 +139,7 @@ parseKind ["binf", b,q] = KindBinFreq {binSize=read b, delims =read ("["++q++"]")} parseKind ["binc", b,q] = KindBinCount {binSize=read b, delims =read ("["++q++"]")} parseKind ["value" ] = KindValue+ parseKind ("duration":ws) = KindDuration {subKind=parseKind ws} parseKind ["none" ] = KindNone parseKind ws = error ("Unknown diagram kind" ++ unwords ws) @@ -185,7 +197,9 @@ times = sort $ [t | tes <- M.elems track2events, (t,_)<- tes] commonTimeAxis = autoAxis times - plotTrack name es = case (chartKindF name) of+ plotTrack name es = plotWithKind name (chartKindF name) es++ plotWithKind name k es = case k of KindHistogram bs -> withAnyOrdinate $ plotTrackHistogram name es bs KindFreq bs k -> withAnyOrdinate $ plotTrackFreq name es bs k KindCount bs k -> withAnyOrdinate $ plotTrackCount name es bs k@@ -194,6 +208,7 @@ KindBinFreq bs vs -> withAnyOrdinate $ plotTrackBinFreqs name es vs bs KindBinCount bs vs -> withAnyOrdinate $ plotTrackBinCounts name es vs bs KindValue -> withAnyOrdinate $ plotTrackValue name es+ KindDuration sk -> plotWithKind name sk (edges2durations (edges es)) KindNone -> error "KindNone should not be plotted" edges es = [(t,e) | (t,InEdge e) <- es]@@ -282,6 +297,9 @@ layout1_margin ^= 0 $ defaultLayout1 +edges2durations :: forall t. (Ord t, HasDelta t) => [(t,Edge)] -> [(t,InEvent)]+edges2durations tes = [(t1, InValue $ toSeconds (t2 `sub` t1) (undefined::t)) | LongEvent t1 t2 () <- edges2events tes]+ edges2events :: (Ord t) => [(t,Edge)] -> [Event t ()] edges2events tes = longs `merge` pulses where@@ -393,7 +411,7 @@ " (for instance, line numbers); 'date PATTERN' means that times are dates", " in the format specified by PATTERN - see http://linux.die.net/man/3/strptime,", " for example, [%Y-%m-%d %H:%M:%S] parses dates like [2009-10-20 16:52:43]. ",- " We also support %OS for fractional seconds (i.e. %OS will parse 12.4039).",+ " We also support %OS for fractional seconds (i.e. %OS will parse 12.4039 or 12,4039).", " Default: 'date %Y-%m-%d %H:%M:%OS'", " -k P K - set diagram kind for tracks matching pattern P to K ", " (-k clauses are matched till first success)",@@ -437,7 +455,7 @@ when (null args || args == ["--help"]) $ showHelp >> exitSuccess let conf = readConf args let render = case (outFormat conf) of {- PNG -> renderableToPNGFile ;+ PNG -> \c w h f -> const () `fmap` renderableToPNGFile c w h f; PDF -> renderableToPDFFile ; PS -> renderableToPSFile ; SVG -> renderableToSVGFile ;
timeplot.cabal view
@@ -1,5 +1,5 @@ Name: timeplot-Version: 0.1.7+Version: 0.1.8 License: BSD3 License-file: LICENSE Copyright: Eugene Kirpichov, 2009