module Simulation.Aivika.Experiment.Base.SamplingStatsWriter
(SamplingStatsWriter(..),
defaultSamplingStatsWriter) where
import Simulation.Aivika.Experiment.Types
import Simulation.Aivika.Experiment.Base.HtmlWriter
import Simulation.Aivika.Statistics
data SamplingStatsWriter a =
SamplingStatsWriter { forall a. SamplingStatsWriter a -> Int
samplingStatsWidth :: Int,
forall a. SamplingStatsWriter a -> String
samplingStatsMeanText :: String,
forall a. SamplingStatsWriter a -> String
samplingStatsDeviationText :: String,
forall a. SamplingStatsWriter a -> String
samplingStatsMinText :: String,
forall a. SamplingStatsWriter a -> String
samplingStatsMaxText :: String,
forall a. SamplingStatsWriter a -> String
samplingStatsCountText :: String,
forall a. SamplingStatsWriter a -> ShowS
samplingStatsFormatter :: ShowS,
forall a.
SamplingStatsWriter a
-> SamplingStatsWriter a
-> String
-> SamplingStats a
-> HtmlWriter ()
samplingStatsWrite :: SamplingStatsWriter a -> String ->
SamplingStats a -> HtmlWriter ()
}
defaultSamplingStatsWriter :: Show a => SamplingStatsWriter a
defaultSamplingStatsWriter :: forall a. Show a => SamplingStatsWriter a
defaultSamplingStatsWriter =
SamplingStatsWriter {
samplingStatsWidth :: Int
samplingStatsWidth = Int
400,
samplingStatsMeanText :: String
samplingStatsMeanText = String
"mean",
samplingStatsDeviationText :: String
samplingStatsDeviationText = String
"deviation",
samplingStatsMinText :: String
samplingStatsMinText = String
"minimum",
samplingStatsMaxText :: String
samplingStatsMaxText = String
"maximum",
samplingStatsCountText :: String
samplingStatsCountText = String
"count",
samplingStatsFormatter :: ShowS
samplingStatsFormatter = ShowS
forall a. a -> a
id,
samplingStatsWrite :: SamplingStatsWriter a -> String -> SamplingStats a -> HtmlWriter ()
samplingStatsWrite = \SamplingStatsWriter a
writer String
name SamplingStats a
stats ->
do let format :: ShowS
format String
x = SamplingStatsWriter a -> ShowS
forall a. SamplingStatsWriter a -> ShowS
samplingStatsFormatter SamplingStatsWriter a
writer String
x
String -> HtmlWriter ()
writeHtml String
"<p>"
String -> HtmlWriter ()
writeHtml String
"<table frame='border' cellspacing='4' width='"
String -> HtmlWriter ()
writeHtml (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ SamplingStatsWriter a -> Int
forall a. SamplingStatsWriter a -> Int
samplingStatsWidth SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"'>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='2'>"
String -> HtmlWriter ()
writeHtml String
"<p align='center'>"
String -> HtmlWriter ()
writeHtmlText String
name
String -> HtmlWriter ()
writeHtml String
"</h4>"
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ SamplingStatsWriter a -> String
forall a. SamplingStatsWriter a -> String
samplingStatsMeanText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ ShowS
format ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Double -> String
forall a. Show a => a -> String
show (Double -> String) -> Double -> String
forall a b. (a -> b) -> a -> b
$ SamplingStats a -> Double
forall a. SamplingStats a -> Double
samplingStatsMean SamplingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ SamplingStatsWriter a -> String
forall a. SamplingStatsWriter a -> String
samplingStatsDeviationText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ ShowS
format ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Double -> String
forall a. Show a => a -> String
show (Double -> String) -> Double -> String
forall a b. (a -> b) -> a -> b
$ SamplingStats a -> Double
forall a. SamplingStats a -> Double
samplingStatsDeviation SamplingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ SamplingStatsWriter a -> String
forall a. SamplingStatsWriter a -> String
samplingStatsMinText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ ShowS
format ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ a -> String
forall a. Show a => a -> String
show (a -> String) -> a -> String
forall a b. (a -> b) -> a -> b
$ SamplingStats a -> a
forall a. SamplingStats a -> a
samplingStatsMin SamplingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ SamplingStatsWriter a -> String
forall a. SamplingStatsWriter a -> String
samplingStatsMaxText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ ShowS
format ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ a -> String
forall a. Show a => a -> String
show (a -> String) -> a -> String
forall a b. (a -> b) -> a -> b
$ SamplingStats a -> a
forall a. SamplingStats a -> a
samplingStatsMax SamplingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ SamplingStatsWriter a -> String
forall a. SamplingStatsWriter a -> String
samplingStatsCountText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtml (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ ShowS
format ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ SamplingStats a -> Int
forall a. SamplingStats a -> Int
samplingStatsCount SamplingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"</table>"
String -> HtmlWriter ()
writeHtml String
"</p>"
}