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 = 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 = 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 forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ 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 forall a b. (a -> b) -> a -> b
$ forall a. TimingStatsWriter a -> String
timingStatsMeanText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='2'>"
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. 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 forall a b. (a -> b) -> a -> b
$ forall a. TimingStatsWriter a -> String
timingStatsDeviationText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td colspan='2'>"
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. 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 forall a b. (a -> b) -> a -> b
$ forall a. TimingStatsWriter a -> String
timingStatsMinText TimingStatsWriter 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. TimingStats a -> a
timingStatsMin TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText String
"("
String -> HtmlWriter ()
writeHtmlText forall a b. (a -> b) -> a -> b
$ forall a. TimingStatsWriter a -> String
timingStatsTimeText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtmlText String
" = "
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. 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 forall a b. (a -> b) -> a -> b
$ forall a. TimingStatsWriter a -> String
timingStatsMaxText TimingStatsWriter 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. TimingStats a -> a
timingStatsMax TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"</td>"
String -> HtmlWriter ()
writeHtml String
"<td>"
String -> HtmlWriter ()
writeHtmlText String
"("
String -> HtmlWriter ()
writeHtmlText forall a b. (a -> b) -> a -> b
$ forall a. TimingStatsWriter a -> String
timingStatsTimeText TimingStatsWriter a
writer
String -> HtmlWriter ()
writeHtmlText String
" = "
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. 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 forall a b. (a -> b) -> a -> b
$ 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 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. TimingStats a -> Double
timingStatsStartTime TimingStats a
stats
String -> HtmlWriter ()
writeHtml String
"; "
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. 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>"
}