diff --git a/README.md b/README.md index 8010274..18b0585 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ speedscope is designed to ingest profiles from a variety of different profilers - Native code - [Importing from Instruments.app](https://github.com/jlfwong/speedscope/wiki/Importing-from-Instruments.app) (macOS) - [Importing from `perf`](https://github.com/jlfwong/speedscope/wiki/Importing-from-perf-(linux)) (linux) +- [Importing from GHC (Haskell)](https://github.com/jlfwong/speedscope/wiki/Importing-from-Haskell) - [Importing from custom sources](https://github.com/jlfwong/speedscope/wiki/Importing-from-custom-sources) Contributions to add support for additional formats are welcome! See issues with the ["import source" tag](https://github.com/jlfwong/speedscope/issues?q=is%3Aissue+is%3Aopen+label%3A%22import+source%22). diff --git a/sample/profiles/haskell/simple.prof b/sample/profiles/haskell/simple.prof new file mode 100644 index 0000000..43f153c --- /dev/null +++ b/sample/profiles/haskell/simple.prof @@ -0,0 +1,193 @@ +{ +"program": "binary-trees", +"arguments": ["binary-trees"], +"rts_arguments": ["-pj"], +"end_time": "Thu Oct 25 10:51 2018", +"initial_capabilities": 0, +"total_time": 0.80, +"total_ticks": 798, +"tick_interval": 1000, +"total_alloc":1921672664, +"cost_centres": [ +{"id": 150, "label": "IDLE", "module": "IDLE", "src_loc": "", "is_caf": false}, {"id": 149, "label": "PINNED", "module": "SYSTEM", "src_loc": "", "is_caf": false}, {"id": 148, "label": "DONT_CARE", "module": "MAIN", "src_loc": "", "is_caf": false}, {"id": 147, "label": "OVERHEAD_of", "module": "PROFILING", "src_loc": "", "is_caf": false}, {"id": 146, "label": "GC", "module": "GC", "src_loc": "", "is_caf": false}, {"id": 145, "label": "SYSTEM", "module": "SYSTEM", "src_loc": "", "is_caf": false}, {"id": 144, "label": "MAIN", "module": "MAIN", "src_loc": "", "is_caf": false}, {"id": 143, "label": "CAF", "module": "GHC.Types", "src_loc": "", "is_caf": true}, {"id": 142, "label": "CAF", "module": "GHC.Tuple", "src_loc": "", "is_caf": true}, {"id": 141, "label": "CAF", "module": "GHC.Classes", "src_loc": "", "is_caf": true}, {"id": 140, "label": "CAF", "module": "GHC.CString", "src_loc": "", "is_caf": true}, {"id": 139, "label": "CAF", "module": "GHC.Integer.Type", "src_loc": "", "is_caf": true}, {"id": 138, "label": "CAF", "module": "GHC.Integer.Logarithms.Internals", "src_loc": "", "is_caf": true}, {"id": 137, "label": "CAF", "module": "GHC.Integer.Logarithms", "src_loc": "", "is_caf": true}, {"id": 136, "label": "CAF", "module": "GHC.Event.Unique", "src_loc": "", "is_caf": true}, {"id": 135, "label": "CAF", "module": "GHC.Event.TimerManager", "src_loc": "", "is_caf": true}, {"id": 134, "label": "CAF", "module": "GHC.Event.Thread", "src_loc": "", "is_caf": true}, {"id": 133, "label": "CAF", "module": "GHC.Event.Poll", "src_loc": "", "is_caf": true}, {"id": 132, "label": "CAF", "module": "GHC.Event.PSQ", "src_loc": "", "is_caf": true}, {"id": 131, "label": "CAF", "module": "GHC.Event.Manager", "src_loc": "", "is_caf": true}, {"id": 130, "label": "CAF", "module": "GHC.Event.KQueue", "src_loc": "", "is_caf": true}, {"id": 129, "label": "CAF", "module": "GHC.Event.Internal", "src_loc": "", "is_caf": true}, {"id": 128, "label": "CAF", "module": "GHC.Event.IntTable", "src_loc": "", "is_caf": true}, {"id": 127, "label": "CAF", "module": "GHC.Event.Control", "src_loc": "", "is_caf": true}, {"id": 126, "label": "CAF", "module": "GHC.Event.Array", "src_loc": "", "is_caf": true}, {"id": 125, "label": "CAF", "module": "GHC.Event.Arr", "src_loc": "", "is_caf": true}, {"id": 124, "label": "CAF", "module": "Data.Typeable.Internal", "src_loc": "", "is_caf": true}, {"id": 123, "label": "CAF", "module": "Data.Semigroup.Internal", "src_loc": "", "is_caf": true}, {"id": 122, "label": "CAF", "module": "Data.OldList", "src_loc": "", "is_caf": true}, {"id": 121, "label": "CAF", "module": "Text.Read.Lex", "src_loc": "", "is_caf": true}, {"id": 120, "label": "CAF", "module": "Text.Read", "src_loc": "", "is_caf": true}, {"id": 119, "label": "CAF", "module": "Text.Printf", "src_loc": "", "is_caf": true}, {"id": 118, "label": "CAF", "module": "Text.ParserCombinators.ReadPrec", "src_loc": "", "is_caf": true}, {"id": 117, "label": "CAF", "module": "Text.ParserCombinators.ReadP", "src_loc": "", "is_caf": true}, {"id": 116, "label": "CAF", "module": "System.Posix.Types", "src_loc": "", "is_caf": true}, {"id": 115, "label": "CAF", "module": "System.Posix.Internals", "src_loc": "", "is_caf": true}, {"id": 114, "label": "CAF", "module": "System.IO", "src_loc": "", "is_caf": true}, {"id": 113, "label": "CAF", "module": "Numeric", "src_loc": "", "is_caf": true}, {"id": 112, "label": "CAF", "module": "GHC.Word", "src_loc": "", "is_caf": true}, {"id": 111, "label": "CAF", "module": "GHC.Weak", "src_loc": "", "is_caf": true}, {"id": 110, "label": "CAF", "module": "GHC.Unicode", "src_loc": "", "is_caf": true}, {"id": 109, "label": "CAF", "module": "GHC.TypeNats", "src_loc": "", "is_caf": true}, {"id": 108, "label": "CAF", "module": "GHC.TypeLits", "src_loc": "", "is_caf": true}, {"id": 107, "label": "CAF", "module": "GHC.TopHandler", "src_loc": "", "is_caf": true}, {"id": 106, "label": "CAF", "module": "GHC.Storable", "src_loc": "", "is_caf": true}, {"id": 105, "label": "CAF", "module": "GHC.Stack.Types", "src_loc": "", "is_caf": true}, {"id": 104, "label": "CAF", "module": "GHC.Stack.CCS", "src_loc": "", "is_caf": true}, {"id": 103, "label": "CAF", "module": "GHC.Stable", "src_loc": "", "is_caf": true}, {"id": 102, "label": "CAF", "module": "GHC.Show", "src_loc": "", "is_caf": true}, {"id": 101, "label": "CAF", "module": "GHC.STRef", "src_loc": "", "is_caf": true}, {"id": 100, "label": "CAF", "module": "GHC.ST", "src_loc": "", "is_caf": true}, {"id": 99, "label": "CAF", "module": "GHC.Real", "src_loc": "", "is_caf": true}, {"id": 98, "label": "CAF", "module": "GHC.Read", "src_loc": "", "is_caf": true}, {"id": 97, "label": "CAF", "module": "GHC.Ptr", "src_loc": "", "is_caf": true}, {"id": 96, "label": "CAF", "module": "GHC.Pack", "src_loc": "", "is_caf": true}, {"id": 95, "label": "CAF", "module": "GHC.Num", "src_loc": "", "is_caf": true}, {"id": 94, "label": "CAF", "module": "GHC.Natural", "src_loc": "", "is_caf": true}, {"id": 93, "label": "CAF", "module": "GHC.MVar", "src_loc": "", "is_caf": true}, {"id": 92, "label": "CAF", "module": "GHC.List", "src_loc": "", "is_caf": true}, {"id": 91, "label": "CAF", "module": "GHC.Int", "src_loc": "", "is_caf": true}, {"id": 90, "label": "CAF", "module": "GHC.IORef", "src_loc": "", "is_caf": true}, {"id": 89, "label": "CAF", "module": "GHC.IO.Unsafe", "src_loc": "", "is_caf": true}, {"id": 88, "label": "CAF", "module": "GHC.IO.IOMode", "src_loc": "", "is_caf": true}, {"id": 87, "label": "CAF", "module": "GHC.IO.Handle.Types", "src_loc": "", "is_caf": true}, {"id": 86, "label": "CAF", "module": "GHC.IO.Handle.Text", "src_loc": "", "is_caf": true}, {"id": 85, "label": "CAF", "module": "GHC.IO.Handle.Internals", "src_loc": "", "is_caf": true}, {"id": 84, "label": "CAF", "module": "GHC.IO.Handle.FD", "src_loc": "", "is_caf": true}, {"id": 83, "label": "CAF", "module": "GHC.IO.Handle", "src_loc": "", "is_caf": true}, {"id": 82, "label": "CAF", "module": "GHC.IO.FD", "src_loc": "", "is_caf": true}, {"id": 81, "label": "CAF", "module": "GHC.IO.Exception", "src_loc": "", "is_caf": true}, {"id": 80, "label": "CAF", "module": "GHC.IO.Encoding.UTF8", "src_loc": "", "is_caf": true}, {"id": 79, "label": "CAF", "module": "GHC.IO.Encoding.UTF32", "src_loc": "", "is_caf": true}, {"id": 78, "label": "CAF", "module": "GHC.IO.Encoding.UTF16", "src_loc": "", "is_caf": true}, {"id": 77, "label": "CAF", "module": "GHC.IO.Encoding.Types", "src_loc": "", "is_caf": true}, {"id": 76, "label": "CAF", "module": "GHC.IO.Encoding.Latin1", "src_loc": "", "is_caf": true}, {"id": 75, "label": "CAF", "module": "GHC.IO.Encoding.Iconv", "src_loc": "", "is_caf": true}, {"id": 74, "label": "CAF", "module": "GHC.IO.Encoding.Failure", "src_loc": "", "is_caf": true}, {"id": 73, "label": "CAF", "module": "GHC.IO.Encoding", "src_loc": "", "is_caf": true}, {"id": 72, "label": "CAF", "module": "GHC.IO.Device", "src_loc": "", "is_caf": true}, {"id": 71, "label": "CAF", "module": "GHC.IO.BufferedIO", "src_loc": "", "is_caf": true}, {"id": 70, "label": "CAF", "module": "GHC.IO.Buffer", "src_loc": "", "is_caf": true}, {"id": 69, "label": "CAF", "module": "GHC.IO", "src_loc": "", "is_caf": true}, {"id": 68, "label": "CAF", "module": "GHC.Generics", "src_loc": "", "is_caf": true}, {"id": 67, "label": "CAF", "module": "GHC.ForeignPtr", "src_loc": "", "is_caf": true}, {"id": 66, "label": "CAF", "module": "GHC.Foreign", "src_loc": "", "is_caf": true}, {"id": 65, "label": "CAF", "module": "GHC.Float.RealFracMethods", "src_loc": "", "is_caf": true}, {"id": 64, "label": "CAF", "module": "GHC.Float.ConversionUtils", "src_loc": "", "is_caf": true}, {"id": 63, "label": "CAF", "module": "GHC.Float", "src_loc": "", "is_caf": true}, {"id": 62, "label": "CAF", "module": "GHC.Fingerprint.Type", "src_loc": "", "is_caf": true}, {"id": 61, "label": "CAF", "module": "GHC.Fingerprint", "src_loc": "", "is_caf": true}, {"id": 60, "label": "CAF", "module": "GHC.Exception", "src_loc": "", "is_caf": true}, {"id": 59, "label": "CAF", "module": "GHC.Err", "src_loc": "", "is_caf": true}, {"id": 58, "label": "CAF", "module": "GHC.Enum", "src_loc": "", "is_caf": true}, {"id": 57, "label": "CAF", "module": "GHC.Conc.Sync", "src_loc": "", "is_caf": true}, {"id": 56, "label": "CAF", "module": "GHC.Conc.Signal", "src_loc": "", "is_caf": true}, {"id": 55, "label": "CAF", "module": "GHC.Conc.IO", "src_loc": "", "is_caf": true}, {"id": 54, "label": "CAF", "module": "GHC.Char", "src_loc": "", "is_caf": true}, {"id": 53, "label": "CAF", "module": "GHC.Base", "src_loc": "", "is_caf": true}, {"id": 52, "label": "CAF", "module": "GHC.Arr", "src_loc": "", "is_caf": true}, {"id": 51, "label": "CAF", "module": "Foreign.Storable", "src_loc": "", "is_caf": true}, {"id": 50, "label": "CAF", "module": "Foreign.Marshal.Array", "src_loc": "", "is_caf": true}, {"id": 49, "label": "CAF", "module": "Foreign.Marshal.Alloc", "src_loc": "", "is_caf": true}, {"id": 48, "label": "CAF", "module": "Foreign.C.Types", "src_loc": "", "is_caf": true}, {"id": 47, "label": "CAF", "module": "Foreign.C.String", "src_loc": "", "is_caf": true}, {"id": 46, "label": "CAF", "module": "Foreign.C.Error", "src_loc": "", "is_caf": true}, {"id": 45, "label": "CAF", "module": "Data.Type.Equality", "src_loc": "", "is_caf": true}, {"id": 44, "label": "CAF", "module": "Data.Tuple", "src_loc": "", "is_caf": true}, {"id": 43, "label": "CAF", "module": "Data.Proxy", "src_loc": "", "is_caf": true}, {"id": 42, "label": "CAF", "module": "Data.Maybe", "src_loc": "", "is_caf": true}, {"id": 41, "label": "CAF", "module": "Data.Either", "src_loc": "", "is_caf": true}, {"id": 40, "label": "CAF", "module": "Data.Dynamic", "src_loc": "", "is_caf": true}, {"id": 39, "label": "CAF", "module": "Data.Bits", "src_loc": "", "is_caf": true}, {"id": 38, "label": "CAF", "module": "Control.Monad.Fail", "src_loc": "", "is_caf": true}, {"id": 37, "label": "CAF", "module": "Control.Exception.Base", "src_loc": "", "is_caf": true}, {"id": 36, "label": "CAF:minN", "module": "Main", "src_loc": "src/Main.hs:17:1-4", "is_caf": true}, {"id": 35, "label": "CAF:io1", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 34, "label": "CAF:main_n", "module": "Main", "src_loc": "src/Main.hs:22:9", "is_caf": true}, {"id": 33, "label": "CAF:main_maxN", "module": "Main", "src_loc": "src/Main.hs:23:9-12", "is_caf": true}, {"id": 32, "label": "CAF:main_stretchN", "module": "Main", "src_loc": "src/Main.hs:24:9-16", "is_caf": true}, {"id": 31, "label": "CAF:main7", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 30, "label": "CAF:main12", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 29, "label": "CAF:main11", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 28, "label": "CAF:eta_r6nG", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 27, "label": "CAF:lvl2_r6nH", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 26, "label": "CAF:eta1_r6nI", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 25, "label": "CAF:main9", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 24, "label": "CAF:lvl4_r6nL", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 23, "label": "CAF:main5", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 22, "label": "CAF:lvl8_r6nP", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 21, "label": "CAF:main1", "module": "Main", "src_loc": "", "is_caf": true}, {"id": 20, "label": "CAF:main", "module": "Main", "src_loc": "src/Main.hs:21:1-4", "is_caf": true}, {"id": 19, "label": "main", "module": "Main", "src_loc": "src/Main.hs:(21,1)-(38,42)", "is_caf": false}, {"id": 18, "label": "main.\\", "module": "Main", "src_loc": "src/Main.hs:35:26-54", "is_caf": false}, {"id": 17, "label": "main.vs", "module": "Main", "src_loc": "src/Main.hs:34:9-28", "is_caf": false}, {"id": 16, "label": "main.long", "module": "Main", "src_loc": "src/Main.hs:31:9-29", "is_caf": false}, {"id": 15, "label": "main.c", "module": "Main", "src_loc": "src/Main.hs:27:9-35", "is_caf": false}, {"id": 14, "label": "main.stretchN", "module": "Main", "src_loc": "src/Main.hs:24:9-27", "is_caf": false}, {"id": 13, "label": "main.maxN", "module": "Main", "src_loc": "src/Main.hs:23:9-35", "is_caf": false}, {"id": 12, "label": "main.n", "module": "Main", "src_loc": "src/Main.hs:22:9-14", "is_caf": false}, {"id": 11, "label": "depth", "module": "Main", "src_loc": "src/Main.hs:(42,1)-(45,38)", "is_caf": false}, {"id": 10, "label": "depth.n", "module": "Main", "src_loc": "src/Main.hs:45:9-38", "is_caf": false}, {"id": 9, "label": "minN", "module": "Main", "src_loc": "src/Main.hs:17:1-8", "is_caf": false}, {"id": 8, "label": "io", "module": "Main", "src_loc": "src/Main.hs:19:1-56", "is_caf": false}, {"id": 7, "label": "sumT", "module": "Main", "src_loc": "src/Main.hs:(49,1)-(52,31)", "is_caf": false}, {"id": 6, "label": "sumT.a", "module": "Main", "src_loc": "src/Main.hs:51:9-31", "is_caf": false}, {"id": 5, "label": "sumT.b", "module": "Main", "src_loc": "src/Main.hs:52:9-31", "is_caf": false}, {"id": 4, "label": "check", "module": "Main", "src_loc": "src/Main.hs:(56,1)-(57,42)", "is_caf": false}, {"id": 3, "label": "make", "module": "Main", "src_loc": "src/Main.hs:(61,1)-(63,26)", "is_caf": false}, {"id": 2, "label": "make.i2", "module": "Main", "src_loc": "src/Main.hs:63:9-16", "is_caf": false}, {"id": 1, "label": "make.d2", "module": "Main", "src_loc": "src/Main.hs:63:19-26", "is_caf": false}] +, +"profile": {"id": 144, "entries": 0, "alloc": 648, "ticks": 0, "children": [{"id": 37, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 38, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 39, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 40, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 41, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 42, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 43, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 44, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 45, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 46, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 47, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 48, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 49, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 50, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 51, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 52, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 53, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 54, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 55, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 56, "entries": 0, "alloc": 640, "ticks": 0, "children": []} +,{"id": 57, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 58, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 59, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 60, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 61, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 62, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 63, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 64, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 65, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 66, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 67, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 68, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 69, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 70, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 71, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 72, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 73, "entries": 0, "alloc": 2768, "ticks": 0, "children": []} +,{"id": 74, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 75, "entries": 0, "alloc": 200, "ticks": 0, "children": []} +,{"id": 76, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 77, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 78, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 79, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 80, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 81, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 82, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 83, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 84, "entries": 0, "alloc": 34704, "ticks": 0, "children": []} +,{"id": 85, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 86, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 87, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 88, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 89, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 90, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 91, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 92, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 93, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 94, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 95, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 96, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 97, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 98, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 99, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 100, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 101, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 102, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 103, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 104, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 105, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 106, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 107, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 108, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 109, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 110, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 111, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 112, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 113, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 114, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 115, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 116, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 117, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 118, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 119, "entries": 0, "alloc": 528, "ticks": 0, "children": []} +,{"id": 120, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 121, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 122, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 123, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 124, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 125, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 126, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 127, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 128, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 129, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 130, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 131, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 132, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 133, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 134, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 135, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 136, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 137, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 138, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 139, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 140, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 141, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 142, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 143, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 26, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 32, "ticks": 0, "children": [{"id": 4, "entries": 131071, "alloc": 2097120, "ticks": 1, "children": []} +,{"id": 16, "entries": 1, "alloc": 0, "ticks": 0, "children": []} +]} +]} +,{"id": 28, "entries": 0, "alloc": 1096, "ticks": 0, "children": []} +,{"id": 35, "entries": 0, "alloc": 1888, "ticks": 0, "children": []} +,{"id": 27, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 16, "entries": 0, "alloc": 32, "ticks": 0, "children": [{"id": 3, "entries": 65535, "alloc": 7864080, "ticks": 3, "children": [{"id": 1, "entries": 32767, "alloc": 0, "ticks": 0, "children": []} +,{"id": 2, "entries": 32767, "alloc": 0, "ticks": 0, "children": []} +]} +]} +]} +]} +,{"id": 24, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 8, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +]} +]} +,{"id": 22, "entries": 0, "alloc": 520, "ticks": 0, "children": []} +,{"id": 20, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 21, "entries": 0, "alloc": 16, "ticks": 0, "children": [{"id": 19, "entries": 1, "alloc": 0, "ticks": 0, "children": []} +]} +,{"id": 29, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 15, "entries": 1, "alloc": 32, "ticks": 0, "children": [{"id": 4, "entries": 262143, "alloc": 4194272, "ticks": 4, "children": []} +]} +]} +]} +,{"id": 30, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 15, "entries": 0, "alloc": 32, "ticks": 0, "children": [{"id": 3, "entries": 131071, "alloc": 15728400, "ticks": 4, "children": [{"id": 1, "entries": 65535, "alloc": 0, "ticks": 0, "children": []} +,{"id": 2, "entries": 65535, "alloc": 0, "ticks": 0, "children": []} +]} +]} +]} +]} +,{"id": 23, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 8, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +]} +]} +,{"id": 31, "entries": 0, "alloc": 880, "ticks": 0, "children": []} +,{"id": 25, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 8, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +]} +]} +,{"id": 33, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 13, "entries": 1, "alloc": 32, "ticks": 0, "children": []} +]} +]} +,{"id": 34, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 12, "entries": 1, "alloc": 0, "ticks": 0, "children": []} +]} +]} +,{"id": 32, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 14, "entries": 1, "alloc": 32, "ticks": 0, "children": []} +]} +]} +,{"id": 36, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 9, "entries": 1, "alloc": 0, "ticks": 0, "children": []} +]} +,{"id": 148, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 146, "entries": 0, "alloc": 0, "ticks": 46, "children": []} +,{"id": 150, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 147, "entries": 0, "alloc": 2496, "ticks": 0, "children": []} +,{"id": 149, "entries": 0, "alloc": 0, "ticks": 0, "children": []} +,{"id": 145, "entries": 0, "alloc": 34736, "ticks": 19, "children": []} +,{"id": 19, "entries": 0, "alloc": 0, "ticks": 0, "children": [{"id": 18, "entries": 6, "alloc": 2224, "ticks": 0, "children": [{"id": 8, "entries": 6, "alloc": 44448, "ticks": 0, "children": []} +]} +,{"id": 8, "entries": 2, "alloc": 23464, "ticks": 0, "children": []} +,{"id": 17, "entries": 1, "alloc": 0, "ticks": 0, "children": [{"id": 11, "entries": 7, "alloc": 1120, "ticks": 0, "children": [{"id": 7, "entries": 43686, "alloc": 0, "ticks": 0, "children": [{"id": 6, "entries": 43680, "alloc": 1397760, "ticks": 3, "children": [{"id": 4, "entries": 12539232, "alloc": 199928832, "ticks": 153, "children": []} +,{"id": 3, "entries": 6247776, "alloc": 744491520, "ticks": 210, "children": [{"id": 1, "entries": 3102048, "alloc": 0, "ticks": 2, "children": []} +,{"id": 2, "entries": 3102048, "alloc": 0, "ticks": 1, "children": []} +]} +]} +,{"id": 5, "entries": 43680, "alloc": 1397760, "ticks": 1, "children": [{"id": 4, "entries": 12539232, "alloc": 199928832, "ticks": 162, "children": []} +,{"id": 3, "entries": 6247776, "alloc": 744491520, "ticks": 189, "children": [{"id": 1, "entries": 3102048, "alloc": 0, "ticks": 0, "children": []} +,{"id": 2, "entries": 3102048, "alloc": 0, "ticks": 0, "children": []} +]} +]} +]} +,{"id": 10, "entries": 7, "alloc": 0, "ticks": 0, "children": []} +]} +]} +]} +]} +} diff --git a/src/import/__snapshots__/haskell.test.ts.snap b/src/import/__snapshots__/haskell.test.ts.snap new file mode 100644 index 0000000..45a406b --- /dev/null +++ b/src/import/__snapshots__/haskell.test.ts.snap @@ -0,0 +1,864 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`importFromHaskell 1`] = ` +Object { + "frames": Array [ + Frame { + "col": undefined, + "file": undefined, + "key": 144, + "line": undefined, + "name": "MAIN.MAIN", + "selfWeight": 0, + "totalWeight": 798, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 56, + "line": undefined, + "name": "GHC.Conc.Signal.CAF", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 73, + "line": undefined, + "name": "GHC.IO.Encoding.CAF", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 75, + "line": undefined, + "name": "GHC.IO.Encoding.Iconv.CAF", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 84, + "line": undefined, + "name": "GHC.IO.Handle.FD.CAF", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 119, + "line": undefined, + "name": "Text.Printf.CAF", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 26, + "line": undefined, + "name": "Main.CAF:eta1_r6nI", + "selfWeight": 0, + "totalWeight": 1, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(21,1)-(38,42)", + "key": 19, + "line": undefined, + "name": "Main.main", + "selfWeight": 0, + "totalWeight": 733, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(56,1)-(57,42)", + "key": 4, + "line": undefined, + "name": "Main.check", + "selfWeight": 320, + "totalWeight": 320, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:31:9-29", + "key": 16, + "line": undefined, + "name": "Main.main.long", + "selfWeight": 0, + "totalWeight": 3, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 28, + "line": undefined, + "name": "Main.CAF:eta_r6nG", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 35, + "line": undefined, + "name": "Main.CAF:io1", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 27, + "line": undefined, + "name": "Main.CAF:lvl2_r6nH", + "selfWeight": 0, + "totalWeight": 3, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(61,1)-(63,26)", + "key": 3, + "line": undefined, + "name": "Main.make", + "selfWeight": 406, + "totalWeight": 409, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:63:19-26", + "key": 1, + "line": undefined, + "name": "Main.make.d2", + "selfWeight": 2, + "totalWeight": 2, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:63:9-16", + "key": 2, + "line": undefined, + "name": "Main.make.i2", + "selfWeight": 1, + "totalWeight": 1, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 24, + "line": undefined, + "name": "Main.CAF:lvl4_r6nL", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 22, + "line": undefined, + "name": "Main.CAF:lvl8_r6nP", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 21, + "line": undefined, + "name": "Main.CAF:main1", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 29, + "line": undefined, + "name": "Main.CAF:main11", + "selfWeight": 0, + "totalWeight": 4, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:27:9-35", + "key": 15, + "line": undefined, + "name": "Main.main.c", + "selfWeight": 0, + "totalWeight": 8, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 30, + "line": undefined, + "name": "Main.CAF:main12", + "selfWeight": 0, + "totalWeight": 4, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 23, + "line": undefined, + "name": "Main.CAF:main5", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 31, + "line": undefined, + "name": "Main.CAF:main7", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 25, + "line": undefined, + "name": "Main.CAF:main9", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:23:9-12", + "key": 33, + "line": undefined, + "name": "Main.CAF:main_maxN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:23:9-35", + "key": 13, + "line": undefined, + "name": "Main.main.maxN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:22:9", + "key": 34, + "line": undefined, + "name": "Main.CAF:main_n", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:22:9-14", + "key": 12, + "line": undefined, + "name": "Main.main.n", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:24:9-16", + "key": 32, + "line": undefined, + "name": "Main.CAF:main_stretchN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:24:9-27", + "key": 14, + "line": undefined, + "name": "Main.main.stretchN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:17:1-4", + "key": 36, + "line": undefined, + "name": "Main.CAF:minN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:17:1-8", + "key": 9, + "line": undefined, + "name": "Main.minN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 146, + "line": undefined, + "name": "GC.GC", + "selfWeight": 46, + "totalWeight": 46, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 147, + "line": undefined, + "name": "PROFILING.OVERHEAD_of", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 145, + "line": undefined, + "name": "SYSTEM.SYSTEM", + "selfWeight": 19, + "totalWeight": 19, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:35:26-54", + "key": 18, + "line": undefined, + "name": "Main.main.\\\\", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:19:1-56", + "key": 8, + "line": undefined, + "name": "Main.io", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:34:9-28", + "key": 17, + "line": undefined, + "name": "Main.main.vs", + "selfWeight": 0, + "totalWeight": 721, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(42,1)-(45,38)", + "key": 11, + "line": undefined, + "name": "Main.depth", + "selfWeight": 0, + "totalWeight": 721, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(49,1)-(52,31)", + "key": 7, + "line": undefined, + "name": "Main.sumT", + "selfWeight": 0, + "totalWeight": 721, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:51:9-31", + "key": 6, + "line": undefined, + "name": "Main.sumT.a", + "selfWeight": 3, + "totalWeight": 369, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:52:9-31", + "key": 5, + "line": undefined, + "name": "Main.sumT.b", + "selfWeight": 1, + "totalWeight": 352, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:45:9-38", + "key": 10, + "line": undefined, + "name": "Main.depth.n", + "selfWeight": 0, + "totalWeight": 0, + }, + ], + "name": "binary-trees time", + "stacks": Array [ + "MAIN.MAIN;Main.CAF:eta1_r6nI;Main.main;Main.check 1.00ms", + "MAIN.MAIN;Main.CAF:lvl2_r6nH;Main.main;Main.main.long;Main.make 3.00ms", + "MAIN.MAIN;Main.CAF:main11;Main.main;Main.main.c;Main.check 4.00ms", + "MAIN.MAIN;Main.CAF:main12;Main.main;Main.main.c;Main.make 4.00ms", + "MAIN.MAIN;GC.GC 46.00ms", + "MAIN.MAIN;SYSTEM.SYSTEM 19.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a;Main.check 153.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a;Main.make;Main.make.d2 2.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a;Main.make;Main.make.i2 1.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a;Main.make 210.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a 3.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.b;Main.check 162.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.b;Main.make 189.00ms", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.b 1.00ms", + ], +} +`; + +exports[`importFromHaskell 2`] = ` +Object { + "frames": Array [ + Frame { + "col": undefined, + "file": undefined, + "key": 144, + "line": undefined, + "name": "MAIN.MAIN", + "selfWeight": 648, + "totalWeight": 1921672664, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 56, + "line": undefined, + "name": "GHC.Conc.Signal.CAF", + "selfWeight": 640, + "totalWeight": 640, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 73, + "line": undefined, + "name": "GHC.IO.Encoding.CAF", + "selfWeight": 2768, + "totalWeight": 2768, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 75, + "line": undefined, + "name": "GHC.IO.Encoding.Iconv.CAF", + "selfWeight": 200, + "totalWeight": 200, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 84, + "line": undefined, + "name": "GHC.IO.Handle.FD.CAF", + "selfWeight": 34704, + "totalWeight": 34704, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 119, + "line": undefined, + "name": "Text.Printf.CAF", + "selfWeight": 528, + "totalWeight": 528, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 26, + "line": undefined, + "name": "Main.CAF:eta1_r6nI", + "selfWeight": 0, + "totalWeight": 2097152, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(21,1)-(38,42)", + "key": 19, + "line": undefined, + "name": "Main.main", + "selfWeight": 32, + "totalWeight": 1921591544, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(56,1)-(57,42)", + "key": 4, + "line": undefined, + "name": "Main.check", + "selfWeight": 406149056, + "totalWeight": 406149056, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:31:9-29", + "key": 16, + "line": undefined, + "name": "Main.main.long", + "selfWeight": 32, + "totalWeight": 7864112, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 28, + "line": undefined, + "name": "Main.CAF:eta_r6nG", + "selfWeight": 1096, + "totalWeight": 1096, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 35, + "line": undefined, + "name": "Main.CAF:io1", + "selfWeight": 1888, + "totalWeight": 1888, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 27, + "line": undefined, + "name": "Main.CAF:lvl2_r6nH", + "selfWeight": 0, + "totalWeight": 7864112, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(61,1)-(63,26)", + "key": 3, + "line": undefined, + "name": "Main.make", + "selfWeight": 1512575520, + "totalWeight": 1512575520, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:63:19-26", + "key": 1, + "line": undefined, + "name": "Main.make.d2", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:63:9-16", + "key": 2, + "line": undefined, + "name": "Main.make.i2", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 24, + "line": undefined, + "name": "Main.CAF:lvl4_r6nL", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 22, + "line": undefined, + "name": "Main.CAF:lvl8_r6nP", + "selfWeight": 520, + "totalWeight": 520, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 21, + "line": undefined, + "name": "Main.CAF:main1", + "selfWeight": 16, + "totalWeight": 16, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 29, + "line": undefined, + "name": "Main.CAF:main11", + "selfWeight": 0, + "totalWeight": 4194304, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:27:9-35", + "key": 15, + "line": undefined, + "name": "Main.main.c", + "selfWeight": 64, + "totalWeight": 19922736, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 30, + "line": undefined, + "name": "Main.CAF:main12", + "selfWeight": 0, + "totalWeight": 15728432, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 23, + "line": undefined, + "name": "Main.CAF:main5", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 31, + "line": undefined, + "name": "Main.CAF:main7", + "selfWeight": 880, + "totalWeight": 880, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 25, + "line": undefined, + "name": "Main.CAF:main9", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:23:9-12", + "key": 33, + "line": undefined, + "name": "Main.CAF:main_maxN", + "selfWeight": 0, + "totalWeight": 32, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:23:9-35", + "key": 13, + "line": undefined, + "name": "Main.main.maxN", + "selfWeight": 32, + "totalWeight": 32, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:22:9", + "key": 34, + "line": undefined, + "name": "Main.CAF:main_n", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:22:9-14", + "key": 12, + "line": undefined, + "name": "Main.main.n", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:24:9-16", + "key": 32, + "line": undefined, + "name": "Main.CAF:main_stretchN", + "selfWeight": 0, + "totalWeight": 32, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:24:9-27", + "key": 14, + "line": undefined, + "name": "Main.main.stretchN", + "selfWeight": 32, + "totalWeight": 32, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:17:1-4", + "key": 36, + "line": undefined, + "name": "Main.CAF:minN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:17:1-8", + "key": 9, + "line": undefined, + "name": "Main.minN", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 146, + "line": undefined, + "name": "GC.GC", + "selfWeight": 0, + "totalWeight": 0, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 147, + "line": undefined, + "name": "PROFILING.OVERHEAD_of", + "selfWeight": 2496, + "totalWeight": 2496, + }, + Frame { + "col": undefined, + "file": undefined, + "key": 145, + "line": undefined, + "name": "SYSTEM.SYSTEM", + "selfWeight": 34736, + "totalWeight": 34736, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:35:26-54", + "key": 18, + "line": undefined, + "name": "Main.main.\\\\", + "selfWeight": 2224, + "totalWeight": 46672, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:19:1-56", + "key": 8, + "line": undefined, + "name": "Main.io", + "selfWeight": 67912, + "totalWeight": 67912, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:34:9-28", + "key": 17, + "line": undefined, + "name": "Main.main.vs", + "selfWeight": 0, + "totalWeight": 1891637344, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(42,1)-(45,38)", + "key": 11, + "line": undefined, + "name": "Main.depth", + "selfWeight": 1120, + "totalWeight": 1891637344, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:(49,1)-(52,31)", + "key": 7, + "line": undefined, + "name": "Main.sumT", + "selfWeight": 0, + "totalWeight": 1891636224, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:51:9-31", + "key": 6, + "line": undefined, + "name": "Main.sumT.a", + "selfWeight": 1397760, + "totalWeight": 945818112, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:52:9-31", + "key": 5, + "line": undefined, + "name": "Main.sumT.b", + "selfWeight": 1397760, + "totalWeight": 945818112, + }, + Frame { + "col": undefined, + "file": "src/Main.hs:45:9-38", + "key": 10, + "line": undefined, + "name": "Main.depth.n", + "selfWeight": 0, + "totalWeight": 0, + }, + ], + "name": "binary-trees allocation", + "stacks": Array [ + "MAIN.MAIN;GHC.Conc.Signal.CAF 640 B", + "MAIN.MAIN;GHC.IO.Encoding.CAF 2.70 KB", + "MAIN.MAIN;GHC.IO.Encoding.Iconv.CAF 200 B", + "MAIN.MAIN;GHC.IO.Handle.FD.CAF 33.89 KB", + "MAIN.MAIN;Text.Printf.CAF 528 B", + "MAIN.MAIN;Main.CAF:eta1_r6nI;Main.main;Main.check 2.00 MB", + "MAIN.MAIN;Main.CAF:eta1_r6nI;Main.main 32 B", + "MAIN.MAIN;Main.CAF:eta_r6nG 1.07 KB", + "MAIN.MAIN;Main.CAF:io1 1.84 KB", + "MAIN.MAIN;Main.CAF:lvl2_r6nH;Main.main;Main.main.long;Main.make 7.50 MB", + "MAIN.MAIN;Main.CAF:lvl2_r6nH;Main.main;Main.main.long 32 B", + "MAIN.MAIN;Main.CAF:lvl8_r6nP 520 B", + "MAIN.MAIN;Main.CAF:main1 16 B", + "MAIN.MAIN;Main.CAF:main11;Main.main;Main.main.c;Main.check 4.00 MB", + "MAIN.MAIN;Main.CAF:main11;Main.main;Main.main.c 32 B", + "MAIN.MAIN;Main.CAF:main12;Main.main;Main.main.c;Main.make 15.00 MB", + "MAIN.MAIN;Main.CAF:main12;Main.main;Main.main.c 32 B", + "MAIN.MAIN;Main.CAF:main7 880 B", + "MAIN.MAIN;Main.CAF:main_maxN;Main.main;Main.main.maxN 32 B", + "MAIN.MAIN;Main.CAF:main_stretchN;Main.main;Main.main.stretchN 32 B", + "MAIN.MAIN;PROFILING.OVERHEAD_of 2.44 KB", + "MAIN.MAIN;SYSTEM.SYSTEM 33.92 KB", + "MAIN.MAIN;Main.main;Main.main.\\\\;Main.io 43.41 KB", + "MAIN.MAIN;Main.main;Main.main.\\\\ 2.17 KB", + "MAIN.MAIN;Main.main;Main.io 22.91 KB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a;Main.check 190.67 MB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a;Main.make 710.00 MB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.a 1.33 MB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.b;Main.check 190.67 MB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.b;Main.make 710.00 MB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth;Main.sumT;Main.sumT.b 1.33 MB", + "MAIN.MAIN;Main.main;Main.main.vs;Main.depth 1.09 KB", + "MAIN.MAIN 648 B", + ], +} +`; + +exports[`importFromHaskell: indexToView 1`] = `0`; + +exports[`importFromHaskell: profileGroup.name 1`] = `"binary-trees"`; diff --git a/src/import/haskell.test.ts b/src/import/haskell.test.ts new file mode 100644 index 0000000..a06185b --- /dev/null +++ b/src/import/haskell.test.ts @@ -0,0 +1,5 @@ +import {checkProfileSnapshot} from '../lib/test-utils' + +test('importFromHaskell', async () => { + await checkProfileSnapshot('./sample/profiles/haskell/simple.prof') +}) diff --git a/src/import/haskell.ts b/src/import/haskell.ts new file mode 100644 index 0000000..d97283b --- /dev/null +++ b/src/import/haskell.ts @@ -0,0 +1,98 @@ +import {ProfileGroup, FrameInfo, CallTreeProfileBuilder} from '../lib/profile' +import {TimeFormatter, ByteFormatter} from '../lib/value-formatters' + +// See https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/profiling.html#json-profile-format +// for information on the GHC profiler JSON output format. + +interface CostCentre { + id: number + label: string + module: string + src_loc: string + is_caf: boolean +} + +interface ProfileTree { + id: number + entries: number + alloc: number + ticks: number + children: ProfileTree[] +} + +interface HaskellProfile { + program: string + arguments: string[] + rts_arguments: string[] + end_time: string + initial_capabilities: number + total_time: number + total_ticks: number + tick_interval: number + total_alloc: number + cost_centres: CostCentre[] + profile: ProfileTree +} + +// The profiler already collapses recursion before output so using the JS stack here should be fine +function addToProfile( + tree: ProfileTree, + startVal: number, + profile: CallTreeProfileBuilder, + infos: Map, + attribute: (tree: ProfileTree) => number, +): number { + // If the expression never did anything we don't care about it + if (tree.ticks === 0 && tree.entries === 0 && tree.alloc === 0 && tree.children.length === 0) + return startVal + + let curVal = startVal + let frameInfo = infos.get(tree.id)! + + profile.enterFrame(frameInfo, curVal) + + for (let child of tree.children) { + curVal = addToProfile(child, curVal, profile, infos, attribute) + } + + curVal += attribute(tree) + + profile.leaveFrame(frameInfo, curVal) + + return curVal +} + +export function importFromHaskell(haskellProfile: HaskellProfile): ProfileGroup { + const idToFrameInfo = new Map() + for (let centre of haskellProfile.cost_centres) { + const frameInfo: FrameInfo = { + key: centre.id, + name: `${centre.module}.${centre.label}`, + } + + // Ignore things like and + if (!centre.src_loc.startsWith('<')) { + // This also contains line and column information, but sometimes it contains ranges, + // and in varying formats, so it's a better experience just to leave it as is + frameInfo.file = centre.src_loc + } + + idToFrameInfo.set(centre.id, frameInfo) + } + + const timeProfile = new CallTreeProfileBuilder(haskellProfile.total_ticks) + addToProfile(haskellProfile.profile, 0, timeProfile, idToFrameInfo, tree => tree.ticks) + timeProfile.setValueFormatter(new TimeFormatter('milliseconds')) + timeProfile.setName(`${haskellProfile.program} time`) + + const allocProfile = new CallTreeProfileBuilder(haskellProfile.total_ticks) + addToProfile(haskellProfile.profile, 0, allocProfile, idToFrameInfo, tree => tree.alloc) + allocProfile.setValueFormatter(new ByteFormatter()) + allocProfile.setName(`${haskellProfile.program} allocation`) + + return { + name: haskellProfile.program, + indexToView: 0, + profiles: [timeProfile.build(), allocProfile.build()], + } +} diff --git a/src/import/index.ts b/src/import/index.ts index 64d4ed9..dfc34a1 100644 --- a/src/import/index.ts +++ b/src/import/index.ts @@ -9,6 +9,7 @@ import {importFromFirefox} from './firefox' import {importSpeedscopeProfiles} from '../lib/file-format' import {importFromV8ProfLog} from './v8proflog' import {importFromLinuxPerf} from './linux-tools-perf' +import {importFromHaskell} from './haskell' import {ProfileDataSource, TextProfileDataSource, MaybeCompressedDataReader} from './utils' import {importAsPprofProfile} from './pprof' import {decodeBase64} from '../lib/utils' @@ -136,6 +137,9 @@ async function _importProfileGroup(dataSource: ProfileDataSource): Promise