packages feed

timeplot 1.0.10 → 1.0.11

raw patch · 3 files changed

+30/−32 lines, 3 files

Files

Tools/TimePlot.hs view
@@ -38,7 +38,7 @@ -- Pass 2: --  * Generate plot data (one-pass multiplexed to tracks) -- -makeChart :: (S.ByteString -> [ChartKind LocalTime]) -> +makeChart :: (S.ByteString -> [(ChartKind LocalTime, S.ByteString)]) ->               IO [(LocalTime, InEvent)] ->              Maybe LocalTime -> Maybe LocalTime ->              (LocalTime -> String -> String) -> @@ -49,9 +49,9 @@     then return emptyRenderable     else do       -- Pass 1: find out min/max time and final track names.-      let i2o t KindNone                = []-          i2o t (KindWithin mapName sk) = [(mapName t, sk)]-          i2o t k                       = [(t, k)]+      let i2o t (KindNone,                _) = []+          i2o t (KindWithin mapName sk, suf) = [(S.append (mapName t) suf, sk)]+          i2o t (k,                     suf) = [(S.append t suf, k)]       let i2oTracks t = concatMap (i2o t) (chartKindF t)       let t0 = fst (head events)       let (minTime, maxTime, outTracks) = foldl' @@ -79,7 +79,7 @@   "        See http://www.haskell.org/haskellwiki/Timeplot",   "Usage: tplot [-o OFILE] [-of {png|pdf|ps|svg}] [-or 640x480]",   "             -if IFILE [-tf TF] ",-  "             [{+|-}k Pat1 Kind1 {+|-}k Pat2 Kind2 ...] [{+|-}dk KindN]",+  "             [{+|-}k Pat1 '[+Suf1] Kind1' {+|-}k Pat2 '[+Suf2] Kind2' ...] [{+|-}dk '[+Suf] KindN']",   "             [-fromTime TIME] [-toTime TIME] [-baseTime TIME]",   "  -o  OFILE  - output file",   "  -of        - output format (default: extension of -o)",@@ -106,6 +106,15 @@   "               matched: a track is drawn acc. to all matching +k, to +dk",   "               AND ALSO to the first matching -k, or -dk if none of -k",   "               match",+  "               EXPLANATION OF SUF:",+  "               If '+Suf' is present (e.g. +k request '+frequency freq 60'),",+  "               then '.Suf' is appended to the input track name while mapping it",+  "               to the output track. This is so that a single input track can",+  "               participate in many output tracks - tplot can have only one output",+  "               track with a particular name, so you can't have one track named",+  "               'request' which draws 'freq 60' and another one for 'hist 60' - ",+  "               you should use +k request '+frequency freq 60' +k request '+histogram hist 60'",+  "               and you'll get output tracks 'request.frequency' and 'request.histogram'",   "  -fromTime  - filter records whose time is >= this time",   "               (formatted according to -tf)",   "  -toTime    - filter records whose time is <  this time",@@ -150,14 +159,6 @@   "     group the events by supertrack and for each supertrack draw a graphical track",   "     using the plot type SOMETHING. It's up to SOMETHING to do something with these",   "     events, e.g. 'lines' will simply draw several line plots, one per subtrack.",-  "     WARNING: If you use '+k' to map a single event to multiple 'within' plots, use",-  "     the second form of within with suffix",-  "  'within[C] -> SUF XXXX' - same as within[C] XXXX, but the name of a track like",-  "     'job-JOBID' will be mapped not to 'job' but to 'job->SUF'. This is useful when",-  "     you use it with '+k' - e.g. if you wish to plot both 'duration quantile' and ",-  "     'duration binf' for some requests represented in the trace as '>req.PID'..'<req.PID'",-  "     then use +k req 'within[.] -> qtile quantile ....' +k req 'within[.] -> bins binf ...'",-  "     and you'll get 2 output tracks: req-qtile and req-bins.",   "  'acount N' is for activity counts: a histogram is drawn with granularity",   "     of N time units, where the bin corresponding to [t..t+N) has value",   "     'what was the average number of active events or impulses in that",
Tools/TimePlot/Conf.hs view
@@ -22,7 +22,8 @@   ConcreteConf {
     inFile        :: !FilePath,
     parseTime     :: !(B.ByteString -> Maybe (t, B.ByteString)),
-    chartKindF    :: !(S.ByteString -> [ChartKind t]),
+    -- Input track -> (chart kind, suffix to append to track name for N:1 out:in mapping)
+    chartKindF    :: !(S.ByteString -> [(ChartKind t, S.ByteString)]),
 
     fromTime      :: !(Maybe t),
     toTime        :: !(Maybe t),
@@ -61,11 +62,7 @@         inFile      = single "input file"  "-if" (error "No input file (-if) specified")
         outFile     = single "output file" "-o"  (error "No output file (-o) specified")
         outFormat   = maybe PNG id $ lookup (single "output format" "-of" (name2format outFile)) $
-            [("png",PNG), ("pdf",PDF), ("ps",PS), ("svg",SVG)
-#ifdef HAVE_GTK            
-            , ("x",Window)
-#endif            
-            ]
+            [("png",PNG), ("pdf",PDF), ("ps",PS), ("svg",SVG)]
           where
             name2format = reverse . takeWhile (/='.') . reverse
         outRes      = parseRes $ single "output resolution" "-or" "640x480"
@@ -73,12 +70,12 @@             parseRes s = case break (=='x') s of (h,_:v) -> (read h,read v)
         forceList :: [a] -> ()
         forceList = foldr seq ()
-        chartKindF  = {-# SCC "chartKindF" #-} forceList [forceList plusKinds, forceList minusKinds, forceList defaultKindsPlus, defaultKindMinus `seq` ()] `seq` kindByRegex $
-            [(Cut,        matches regex, parseKind (words kind)) | [regex,kind] <- getArg "-k" 2 args] ++
-            [(Accumulate, matches regex, parseKind (words kind)) | [regex,kind] <- getArg "+k" 2 args]
+        chartKindF  = forceList [forceList plusKinds, forceList minusKinds, forceList defaultKindsPlus, defaultKindMinus `seq` ()] `seq` kindByRegex $
+            [(Cut,        matches regex, parseKind0 (words kind)) | [regex,kind] <- getArg "-k" 2 args] ++
+            [(Accumulate, matches regex, parseKind0 (words kind)) | [regex,kind] <- getArg "+k" 2 args]
           where
-            plusKinds  = [parseKind (words kind) | [regex, kind] <- getArg "+k" 2 args]
-            minusKinds = [parseKind (words kind) | [regex, kind] <- getArg "-k" 2 args]
+            plusKinds  = [parseKind0 (words kind) | [regex, kind] <- getArg "+k" 2 args]
+            minusKinds = [parseKind0 (words kind) | [regex, kind] <- getArg "-k" 2 args]
             kindByRegex rks s = if null specifiedKinds then [defaultKindMinus] else specifiedKinds
               where
                 specifiedKinds = defaultKindsPlus ++
@@ -94,6 +91,9 @@           Nothing -> s
           Just bt -> showDelta t bt
 
+        parseKind0 (('+':suffix):k) = (parseKind k, S.pack "." `S.append` S.pack suffix)
+        parseKind0 k                = (parseKind k, S.empty)
+
         parseKind :: [String] -> ChartKind LocalTime
         parseKind ["acount",  n  ] = KindACount    {binSize=read n}
         parseKind ("acount":_)     = error "acount requires a single numeric argument, bin size, e.g.: -dk 'acount 1'"
@@ -101,11 +101,11 @@         parseKind ("apercent":_)   = error "apercent requires two numeric arguments: bin size and base value, e.g.: -dk 'apercent 1 480'"
         parseKind ["afreq",   n  ] = KindAFreq     {binSize=read n}
         parseKind ("afreq":_)      = error "afreq requires a single numeric argument, bin size, e.g.: -dk 'afreq 1'"
-        parseKind ["freq",    n  ] = KindFreq      {binSize=read n,style=BarsClustered}
+        parseKind ["freq",    n  ] = KindFreq      {binSize=read n,style=BarsStacked}
         parseKind ["freq",    n,s] = KindFreq      {binSize=read n,style=parseStyle s}
         parseKind ("freq":_)       = error $ "freq requires a single numeric argument, bin size, e.g.: -dk 'freq 1', " ++ 
                                              "or two arguments, e.g.: -dk 'freq 1 clustered'"
-        parseKind ["hist",    n  ] = KindHistogram {binSize=read n,style=BarsClustered}
+        parseKind ["hist",    n  ] = KindHistogram {binSize=read n,style=BarsStacked}
         parseKind ["hist",    n,s] = KindHistogram {binSize=read n,style=parseStyle s}
         parseKind ("hist":_)       = error $ "hist requires a single numeric argument, bin size, e.g.: -dk 'hist 1', " ++ 
                                              "or two arguments, e.g.: -dk 'hist 1 clustered'"
@@ -134,9 +134,6 @@         parseKind ("sum":_)        = error $ "sum requires one or two arguments: bin size and optionally " ++ 
                                              "subtrack style, e.g.: -dk 'sum 1' or -dk 'sum 1 stacked'"
         parseKind ("duration":ws)  = KindDuration  {subKind=parseKind ws}
-        parseKind (('w':'i':'t':'h':'i':'n':'[':sep:"]"):"->":suf:ws)
-                                   = let (sp, arr) = (S.pack suf, S.pack "->")
-                                     in KindWithin    {subKind=parseKind ws, mapName = (\x -> S.concat [x, arr, sp]) . fst . S.break (==sep)}
         parseKind (('w':'i':'t':'h':'i':'n':'[':sep:"]"):ws)
                                    = KindWithin    {subKind=parseKind ws, mapName = fst . S.break (==sep)}
         parseKind ["none"        ] = KindNone
@@ -145,8 +142,8 @@         parseKind ("unspecified":_)= error "unspecified requires no arguments"
         parseKind ws               = error ("Unknown diagram kind " ++ unwords ws)
 
-        defaultKindMinus = parseKind $ words $ single "default kind" "-dk" "unspecified"
-        defaultKindsPlus = map (parseKind . words . head) $ getArg "+dk" 1 args
+        defaultKindMinus = parseKind0 $ words $ single "default kind" "-dk" "unspecified"
+        defaultKindsPlus = map (parseKind0 . words . head) $ getArg "+dk" 1 args
 
         parseStyle "stacked"   = BarsStacked
         parseStyle "clustered" = BarsClustered
timeplot.cabal view
@@ -1,5 +1,5 @@ name: timeplot-version: 1.0.10+version: 1.0.11 cabal-version: >=1.6 build-type: Simple license: BSD3