We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Verified Commit 696572fe authored by Camil Staps's avatar Camil Staps 🚀

Add -e option to exclude functions (e.g. useful for blocking ccalls)

parent 9a01fc6a
......@@ -5,6 +5,7 @@ import StdMaybe
import Data.Error
import Data.Func
import qualified Data.Set
import System.CommandLine
import System.File
import System.FilePath
......@@ -33,12 +34,14 @@ import qualified Text.HTML
derive JSONDecode Profile, Stack
:: Options =
{ input :: !FilePath
, output :: !FilePath
{ input :: !FilePath
, output :: !FilePath
, exclude :: !'Data.Set'.Set String
}
defaultOptions =
{ input = ""
, output = ""
{ input = ""
, output = ""
, exclude = 'Data.Set'.newSet
}
Start w
......@@ -57,8 +60,7 @@ Start w
# input = fromJSON (fromString (fromOk input))
| isNothing input
= exit "Could not parse input" w
# input = fromJust input
input & profile = compute_sums_and_sort (lift_garbage_collector input.profile)
# input = prepare args.exclude (fromJust input)
# (ok,f,w) = fopen args.output FWriteText w
| not ok
= exit "Could not open output file" w
......@@ -75,12 +77,36 @@ where
(\op opts -> Ok {opts & output=op})
"OUTPUT"
"The output file"
, Shorthand "-e" "--exclude" $ Option "--exclude"
(\e opts -> Ok {opts & exclude='Data.Set'.insert e opts.exclude})
"MODULE:FUNCTION"
"A function to exclude (may be specified multiple times)"
]
exit err w
# (_,w) = fclose (stderr <<< err <<< '\n') w
= setReturnCode -1 w
prepare :: !('Data.Set'.Set String) !Profile -> Profile
prepare excluded p =
{ p
& profile =
compute_sums_and_sort $
lift_garbage_collector $
(if ('Data.Set'.size excluded==0) id (remove_excluded_functions excluded))
p.profile
}
remove_excluded_functions :: !('Data.Set'.Set String) !Stack -> Stack
remove_excluded_functions excluded s =
{ s
& children =
[ remove_excluded_functions excluded c
\\ c <- s.children
| not ('Data.Set'.member (concat [c.file,":",c.function]) excluded)
]
}
lift_garbage_collector :: !Stack -> Stack
lift_garbage_collector s
# (s,(ticks,calls)) = walk s 0 0
......
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