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 = 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 = 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 forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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 forall a b. (a -> b) -> a -> b
$ forall a. SamplingStatsWriter a -> String
samplingStatsMeanText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText forall a b. (a -> b) -> a -> b
$ ShowS
format forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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 forall a b. (a -> b) -> a -> b
$ forall a. SamplingStatsWriter a -> String
samplingStatsDeviationText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText forall a b. (a -> b) -> a -> b
$ ShowS
format forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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 forall a b. (a -> b) -> a -> b
$ forall a. SamplingStatsWriter a -> String
samplingStatsMinText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText forall a b. (a -> b) -> a -> b
$ ShowS
format forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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 forall a b. (a -> b) -> a -> b
$ forall a. SamplingStatsWriter a -> String
samplingStatsMaxText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText forall a b. (a -> b) -> a -> b
$ ShowS
format forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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 forall a b. (a -> b) -> a -> b
$ forall a. SamplingStatsWriter a -> String
samplingStatsCountText SamplingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtml forall a b. (a -> b) -> a -> b
$ ShowS
format forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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>"
}