module Simulation.Aivika.Experiment.Base.TimingStatsWriter
(TimingStatsWriter(..),
defaultTimingStatsWriter) where
import Simulation.Aivika.Experiment.Types
import Simulation.Aivika.Experiment.Base.HtmlWriter
import Simulation.Aivika.Statistics
data TimingStatsWriter a =
TimingStatsWriter { forall a. TimingStatsWriter a -> Int
timingStatsWidth :: Int,
forall a. TimingStatsWriter a -> String
timingStatsTimeText :: String,
forall a. TimingStatsWriter a -> String
timingStatsMeanText :: String,
forall a. TimingStatsWriter a -> String
timingStatsDeviationText :: String,
forall a. TimingStatsWriter a -> String
timingStatsMinText :: String,
forall a. TimingStatsWriter a -> String
timingStatsMaxText :: String,
forall a. TimingStatsWriter a -> ShowS
timingStatsFormatter :: ShowS,
forall a.
TimingStatsWriter a
-> TimingStatsWriter a -> String -> TimingStats a -> HtmlWriter ()
timingStatsWrite :: TimingStatsWriter a -> String ->
TimingStats a -> HtmlWriter ()
}
defaultTimingStatsWriter :: (Show a, TimingData a) => TimingStatsWriter a
defaultTimingStatsWriter :: forall a. (Show a, TimingData a) => TimingStatsWriter a
defaultTimingStatsWriter =
TimingStatsWriter {
timingStatsWidth :: Int
timingStatsWidth = Int
400,
timingStatsMeanText :: String
timingStatsMeanText = String
"mean",
timingStatsTimeText :: String
timingStatsTimeText = String
"time",
timingStatsDeviationText :: String
timingStatsDeviationText = String
"deviation",
timingStatsMinText :: String
timingStatsMinText = String
"minimum",
timingStatsMaxText :: String
timingStatsMaxText = String
"maximum",
timingStatsFormatter :: ShowS
timingStatsFormatter = ShowS
forall a. a -> a
id,
timingStatsWrite :: TimingStatsWriter a -> String -> TimingStats a -> HtmlWriter ()
timingStatsWrite = \TimingStatsWriter a
writer String
name TimingStats a
stats ->
do let format :: ShowS
format String
x = TimingStatsWriter a -> ShowS
forall a. TimingStatsWriter a -> ShowS
timingStatsFormatter TimingStatsWriter 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
$ TimingStatsWriter a -> Int
forall a. TimingStatsWriter a -> Int
timingStatsWidth TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"'>"
String -> HtmlWriter ()
writeHtml String
"<tr>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='3'>"
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
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsMeanText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='2'>"
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
$ TimingStats a -> Double
forall a. TimingData a => TimingStats a -> Double
timingStatsMean TimingStats 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
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsDeviationText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='2'>"
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
$ TimingStats a -> Double
forall a. TimingData a => TimingStats a -> Double
timingStatsDeviation TimingStats 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
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsMinText TimingStatsWriter 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
$ TimingStats a -> a
forall a. TimingStats a -> a
timingStatsMin TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText String
"("
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsTimeText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtmlText String
" = "
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
$ TimingStats a -> Double
forall a. TimingStats a -> Double
timingStatsMinTime TimingStats a
stats
String -> HtmlWriter ()
writeHtmlText String
")"
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
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsMaxText TimingStatsWriter 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
$ TimingStats a -> a
forall a. TimingStats a -> a
timingStatsMax TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText String
"("
String -> HtmlWriter ()
writeHtmlText (String -> HtmlWriter ()) -> String -> HtmlWriter ()
forall a b. (a -> b) -> a -> b
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsTimeText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtmlText String
" = "
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
$ TimingStats a -> Double
forall a. TimingStats a -> Double
timingStatsMaxTime TimingStats a
stats
String -> HtmlWriter ()
writeHtmlText String
")"
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
$ TimingStatsWriter a -> String
forall a. TimingStatsWriter a -> String
timingStatsTimeText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='2'>"
String -> HtmlWriter ()
writeHtml String
"["
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
$ Double -> String
forall a. Show a => a -> String
show (Double -> String) -> Double -> String
forall a b. (a -> b) -> a -> b
$ TimingStats a -> Double
forall a. TimingStats a -> Double
timingStatsStartTime TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"; "
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
$ Double -> String
forall a. Show a => a -> String
show (Double -> String) -> Double -> String
forall a b. (a -> b) -> a -> b
$ TimingStats a -> Double
forall a. TimingStats a -> Double
timingStatsLastTime TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"]"
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"</tr>"
String -> HtmlWriter ()
writeHtml String
"</table>"
String -> HtmlWriter ()
writeHtml String
"</p>"
}