Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell GHC分析器输出中的Demanling类型类函数_Haskell_Profiler_Ghc_Name Mangling - Fatal编程技术网

Haskell GHC分析器输出中的Demanling类型类函数

Haskell GHC分析器输出中的Demanling类型类函数,haskell,profiler,ghc,name-mangling,Haskell,Profiler,Ghc,Name Mangling,在分析用GHC编写的Haskell程序时,typeclass函数的名称会在.prof文件中被损坏,以区分一个实例的实现与另一个实例的实现。我怎样才能查询这些名称来找出它是哪种类型的实例 例如,假设我有以下程序,其中类型Fast和Slow都实现Show: import Data.List (foldl') sum' = foldl' (+) 0 data Fast = Fast instance Show Fast where show _ = show $ sum' [1 .. 10

在分析用GHC编写的Haskell程序时,typeclass函数的名称会在.prof文件中被损坏,以区分一个实例的实现与另一个实例的实现。我怎样才能查询这些名称来找出它是哪种类型的实例

例如,假设我有以下程序,其中类型
Fast
Slow
都实现
Show

import Data.List (foldl')

sum' = foldl' (+) 0

data Fast = Fast
instance Show Fast where
    show _ = show $ sum' [1 .. 10]

data Slow = Slow
instance Show Slow where
    show _ = show $ sum' [1 .. 100000000]

main = putStrLn (show Fast ++ show Slow)
我使用
-prof-auto-all-caf-all
编译,并使用
+RTS-p
运行。在生成的.prof文件中,我看到顶级成本中心是:

COST CENTRE                    MODULE               %time %alloc

show_an9                       Main                  71.0   83.3
sum'                           Main                  29.0   16.7
在树上,我同样看到(省略不相关的行):


我如何判断
show\u an9
show
Slow
实现,而不是
Fast
\u an9
\u anx
部件是随机生成的。(当我再次编译时,我得到了
\u ane
\u anC

您可以使用
SCC
(设置成本中心)杂注手动插入成本中心:

data Fast = Fast
instance Show Fast where
    show _ = {-# SCC "show(Fast)" #-} show $ sum' [1 .. 10]

data Slow = Slow
instance Show Slow where
    show _ = {-# SCC "show(Slow)" #-} show $ sum' [1 .. 100000000]
配置文件应显示:

  main
   show_an9
    show(Slow)
     sum'
   show_anx
    show(Fast)
  main
   show_an9
    show(Slow)
     sum'
   show_anx
    show(Fast)