Verified Commit 331f49d0 authored by Camil Staps's avatar Camil Staps 🚀

Optimizations

parent 8d8c6bf1
......@@ -33,8 +33,8 @@ import qualified Text.HTML
, lcalls :: !Int
, ccalls :: !Int
, children :: ![Stack]
, cumulative_ticks :: !Maybe Int // Filled in by this application
, cumulative_words :: !Maybe Int // Filled in by this application
, cumulative_ticks :: !Int // Filled in by this application
, cumulative_words :: !Int // Filled in by this application
}
:: Options =
......@@ -155,9 +155,13 @@ where
read_profile_stack f
# (ok,cost_centre,f) = freadi f
| not ok = (unexpected_eof,f)
# (ok,ticks,f) = freadi f
# (ok,ticks_lo,f) = freadi f
| not ok = (unexpected_eof,f)
# (ok,words,f) = freadi f
# (ok,ticks_hi,f) = freadi f
| not ok = (unexpected_eof,f)
# (ok,words_lo,f) = freadi f
| not ok = (unexpected_eof,f)
# (ok,words_hi,f) = freadi f
| not ok = (unexpected_eof,f)
# (ok,scalls,f) = freadi f
| not ok = (unexpected_eof,f)
......@@ -171,14 +175,14 @@ where
| isError children = (Error (fromError children),f)
# profile =
{ cost_centre = cost_centre-1
, ticks = ticks
, words = words
, ticks = ticks_hi<<32 + ticks_lo
, words = words_hi<<32 + words_lo
, scalls = scalls
, lcalls = lcalls
, ccalls = ccalls
, children = fromOk children
, cumulative_ticks = Nothing
, cumulative_words = Nothing
, cumulative_ticks = -1
, cumulative_words = -1
}
= (Ok profile,f)
where
......@@ -252,8 +256,8 @@ lift_garbage_collector cost_centre_id s
, words = 0
, ticks = ticks
, children = []
, cumulative_ticks = Just ticks
, cumulative_words = Just 0
, cumulative_ticks = ticks
, cumulative_words = 0
}
where
walk :: !Stack !Int !Int -> (!Stack, !(!Int,!Int))
......@@ -266,18 +270,12 @@ where
compute_sums_prune_and_sort :: !Int !Int !Stack -> Stack
compute_sums_prune_and_sort gc_id min_cumulative_ticks s
# children = reverse (sort [compute_sums_prune_and_sort gc_id min_cumulative_ticks c \\ c <- s.children])
s & cumulative_ticks = Just (s.ticks + sum [t \\ {cumulative_ticks=Just t} <- children])
s & cumulative_words = Just (s.words + sum [w \\ {cumulative_words=Just w} <- children])
s & children =
[ c \\ c <- children
| fromJust c.cumulative_ticks >= min_cumulative_ticks
|| c.cost_centre==gc_id
]
s & cumulative_ticks = s.ticks + sum [c.cumulative_ticks \\ c <- children]
s & cumulative_words = s.words + sum [c.cumulative_words \\ c <- children]
s & children = [c \\ c <- children | c.cumulative_ticks >= min_cumulative_ticks || c.cost_centre==gc_id]
= s
instance < Stack
where
< a b = fromJust a.cumulative_ticks < fromJust b.cumulative_ticks
instance < Stack where < a b = a.cumulative_ticks < b.cumulative_ticks
instance <<< Profile
where
......@@ -305,7 +303,7 @@ where
<<< "</html>"
write_stack :: !Profile !Stack !*File -> *File
write_stack p s f = write (fromJust s.cumulative_ticks) (fromJust s.cumulative_words) s f
write_stack p s f = write s.cumulative_ticks s.cumulative_words s f
where
write :: !Int !Int !Stack !*File -> *File
write parent_ticks parent_words s f
......@@ -325,22 +323,20 @@ where
<<< "<span class=\"entry-data\">" <<< if (s.lcalls==0) "&nbsp;" (toString s.lcalls) <<< "</span>"
<<< "<span class=\"entry-data\">" <<< if (s.scalls==0) "&nbsp;" (toString s.scalls) <<< "</span>"
<<< "</div>"
# f = foldl (\f c -> write cumulative_ticks cumulative_words c f) f s.children
# f = foldl (\f c -> write s.cumulative_ticks s.cumulative_words c f) f s.children
= f <<< "</div>"
where
cost_centre = p.cost_centres.[s.cost_centre]
cumulative_ticks = fromJust s.cumulative_ticks
ticks = if (isEmpty s.children)
(toString s.ticks)
(concat [toString cumulative_ticks," (",toString s.ticks,")"])
ticks_width = toWidth (toReal cumulative_ticks / toReal parent_ticks)
(concat [toString s.cumulative_ticks," (",toString s.ticks,")"])
ticks_width = toWidth (toReal s.cumulative_ticks / toReal parent_ticks)
cumulative_words = fromJust s.cumulative_words
words = if (isEmpty s.children)
(toString s.words)
(concat [toString cumulative_words," (",toString s.words,")"])
words_width = toWidth (toReal cumulative_words / toReal parent_words)
(concat [toString s.cumulative_words," (",toString s.words,")"])
words_width = toWidth (toReal s.cumulative_words / toReal parent_words)
toWidth :: !Real -> String
toWidth w
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment