Skip to content

Commit

Permalink
Process log more.
Browse files Browse the repository at this point in the history
  • Loading branch information
thealmarty committed Sep 24, 2021
1 parent c9a79ec commit 22f09c9
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 8 deletions.
21 changes: 13 additions & 8 deletions plutus-tx-plugin/executables/profile/Main.hs
Expand Up @@ -24,6 +24,7 @@ import qualified PlutusCore.Default as PLC

import Control.Lens.Combinators (_2)
import Control.Lens.Getter (view)
import Data.List (stripPrefix, uncons)
import Data.Proxy (Proxy (Proxy))
import Data.Text (Text)
import Prettyprinter.Internal (pretty)
Expand Down Expand Up @@ -98,21 +99,25 @@ writeLogToFile fileName values = do
filePath
WriteMode
(\h -> hPutDoc h log)
processed <- processLog filePath
-- processed <- processLog filePath
-- TODO
-- writeFile (filePath<>".stacks") processed
pure ()

processLog :: FilePath -> IO [[String]]
-- processLog :: FilePath -> IO [[String]]
processLog file = do
content <- readFile file
let lEvents =
map
-- @(take i items ++ drop (1 + i) items)@ drop "UTC]" from the list
-- @tail@ strips "[" in the first line and "," in the other lines,
-- @words@ turns it to a list of [time, enter/exit, var]
(tail . words)
-- turn to a list of events
(lines content)
pure $
map
-- @tail@ strips "[" in the first line and "," in the other lines,
-- @words@ turns it to a list of [time, enter/exit, var]
(tail . words)
-- turn to a list of events
(lines content)
-- stripe “[“ and add “ UTC” to the time so I can use read instance of UTCTime
map (stripPrefix "[" . (++ " UTC") . head ) $take 1 lEvents ++ drop 2 lEvents

main :: IO ()
main = do
Expand Down
2 changes: 2 additions & 0 deletions plutus-tx-plugin/executables/profile/addInt
@@ -0,0 +1,2 @@
[ [2021-09-20 16:31:56.760094947 UTC] entering addInt
, [2021-09-20 16:31:56.76009653 UTC] exiting addInt ]
2 changes: 2 additions & 0 deletions plutus-tx-plugin/executables/profile/addInt3
@@ -0,0 +1,2 @@
[ [2021-09-20 16:31:56.76022053 UTC] entering addInt
, [2021-09-20 16:31:56.760222844 UTC] exiting addInt ]
36 changes: 36 additions & 0 deletions plutus-tx-plugin/executables/profile/fact4
@@ -0,0 +1,36 @@
[ [2021-09-20 16:31:56.759669644 UTC] entering fact
, [2021-09-20 16:31:56.759671769 UTC] entering equalsInteger
, [2021-09-20 16:31:56.75967748 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.759679263 UTC] entering subtractInteger
, [2021-09-20 16:31:56.759681838 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.759683451 UTC] entering fact
, [2021-09-20 16:31:56.759684954 UTC] entering equalsInteger
, [2021-09-20 16:31:56.75968817 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.759689623 UTC] entering subtractInteger
, [2021-09-20 16:31:56.759691877 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.759694142 UTC] entering fact
, [2021-09-20 16:31:56.759695595 UTC] entering equalsInteger
, [2021-09-20 16:31:56.75969861 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.759700093 UTC] entering subtractInteger
, [2021-09-20 16:31:56.759702298 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.759703821 UTC] entering fact
, [2021-09-20 16:31:56.759705233 UTC] entering equalsInteger
, [2021-09-20 16:31:56.759708169 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.759709582 UTC] entering subtractInteger
, [2021-09-20 16:31:56.759711706 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.759713088 UTC] entering fact
, [2021-09-20 16:31:56.759714541 UTC] entering equalsInteger
, [2021-09-20 16:31:56.759718038 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.75971912 UTC] exiting fact
, [2021-09-20 16:31:56.759720262 UTC] entering multiplyInteger
, [2021-09-20 16:31:56.759723338 UTC] exiting multiplyInteger
, [2021-09-20 16:31:56.75972401 UTC] exiting fact
, [2021-09-20 16:31:56.759725252 UTC] entering multiplyInteger
, [2021-09-20 16:31:56.759727566 UTC] exiting multiplyInteger
, [2021-09-20 16:31:56.759728218 UTC] exiting fact
, [2021-09-20 16:31:56.75972939 UTC] entering multiplyInteger
, [2021-09-20 16:31:56.759731594 UTC] exiting multiplyInteger
, [2021-09-20 16:31:56.759732246 UTC] exiting fact
, [2021-09-20 16:31:56.759733348 UTC] entering multiplyInteger
, [2021-09-20 16:31:56.759735602 UTC] exiting multiplyInteger
, [2021-09-20 16:31:56.759736303 UTC] exiting fact ]
74 changes: 74 additions & 0 deletions plutus-tx-plugin/executables/profile/fib4
@@ -0,0 +1,74 @@
[ [2021-09-20 16:31:56.758146138 UTC] entering fib
, [2021-09-20 16:31:56.758149555 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758167169 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758170255 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758174664 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758177569 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758181797 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758184432 UTC] entering fib
, [2021-09-20 16:31:56.758187719 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758191947 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758194692 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758200393 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758202167 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758205323 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758207677 UTC] entering fib
, [2021-09-20 16:31:56.758210262 UTC] entering equalsInteger
, [2021-09-20 16:31:56.75821408 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758216665 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758221865 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.75822464 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758227806 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758229289 UTC] entering fib
, [2021-09-20 16:31:56.758231804 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758236974 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758238617 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758243346 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758244358 UTC] exiting fib
, [2021-09-20 16:31:56.758247284 UTC] entering subtractInteger
, [2021-09-20 16:31:56.75825037 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758252785 UTC] entering fib
, [2021-09-20 16:31:56.758256061 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758259928 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758261732 UTC] exiting fib
, [2021-09-20 16:31:56.758262904 UTC] entering addInteger
, [2021-09-20 16:31:56.758266842 UTC] exiting addInteger
, [2021-09-20 16:31:56.758268485 UTC] exiting fib
, [2021-09-20 16:31:56.758270018 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758273034 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758275368 UTC] entering fib
, [2021-09-20 16:31:56.758278054 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758282111 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758284666 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758288383 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758290147 UTC] exiting fib
, [2021-09-20 16:31:56.758293373 UTC] entering addInteger
, [2021-09-20 16:31:56.758296529 UTC] exiting addInteger
, [2021-09-20 16:31:56.75829713 UTC] exiting fib
, [2021-09-20 16:31:56.758299495 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758302531 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758303934 UTC] entering fib
, [2021-09-20 16:31:56.758306398 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758311107 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758312721 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758317329 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758319764 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758323061 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.758324493 UTC] entering fib
, [2021-09-20 16:31:56.758334262 UTC] entering equalsInteger
, [2021-09-20 16:31:56.75833816 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758340685 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758345253 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758346165 UTC] exiting fib
, [2021-09-20 16:31:56.75834843 UTC] entering subtractInteger
, [2021-09-20 16:31:56.758351455 UTC] exiting subtractInteger
, [2021-09-20 16:31:56.75835375 UTC] entering fib
, [2021-09-20 16:31:56.758356205 UTC] entering equalsInteger
, [2021-09-20 16:31:56.758360182 UTC] exiting equalsInteger
, [2021-09-20 16:31:56.758361976 UTC] exiting fib
, [2021-09-20 16:31:56.758363098 UTC] entering addInteger
, [2021-09-20 16:31:56.758366254 UTC] exiting addInteger
, [2021-09-20 16:31:56.758367727 UTC] exiting fib
, [2021-09-20 16:31:56.75836947 UTC] entering addInteger
, [2021-09-20 16:31:56.758372666 UTC] exiting addInteger
, [2021-09-20 16:31:56.75837425 UTC] exiting fib ]
2 changes: 2 additions & 0 deletions plutus-tx-plugin/executables/profile/id
@@ -0,0 +1,2 @@
[ [2021-09-20 16:31:56.760652956 UTC] entering id
, [2021-09-20 16:31:56.760654499 UTC] exiting id ]
6 changes: 6 additions & 0 deletions plutus-tx-plugin/executables/profile/letInFun
@@ -0,0 +1,6 @@
[ [2021-09-20 16:31:56.760336955 UTC] entering addInteger
, [2021-09-20 16:31:56.760340742 UTC] exiting addInteger
, [2021-09-20 16:31:56.760342456 UTC] entering addInteger
, [2021-09-20 16:31:56.76034478 UTC] exiting addInteger
, [2021-09-20 16:31:56.760346213 UTC] entering addInteger
, [2021-09-20 16:31:56.760349048 UTC] exiting addInteger ]
8 changes: 8 additions & 0 deletions plutus-tx-plugin/executables/profile/letInFunMoreArg
@@ -0,0 +1,8 @@
[ [2021-09-20 16:31:56.76050491 UTC] entering addInteger
, [2021-09-20 16:31:56.760508567 UTC] exiting addInteger
, [2021-09-20 16:31:56.7605102 UTC] entering addInteger
, [2021-09-20 16:31:56.760512705 UTC] exiting addInteger
, [2021-09-20 16:31:56.760513867 UTC] entering addInteger
, [2021-09-20 16:31:56.760516051 UTC] exiting addInteger
, [2021-09-20 16:31:56.760517244 UTC] entering multiplyInteger
, [2021-09-20 16:31:56.760519698 UTC] exiting multiplyInteger ]
2 changes: 2 additions & 0 deletions plutus-tx-plugin/executables/profile/swap
@@ -0,0 +1,2 @@
[ [2021-09-20 16:31:56.760796624 UTC] entering swap
, [2021-09-20 16:31:56.760798147 UTC] exiting swap ]

0 comments on commit 22f09c9

Please sign in to comment.