/ / Jak profilować biblioteki? - haskell, cabal

Jak profilować biblioteki? - haskell, cabal

Czy jest jakaś ukryta opcja, która umieści centra kosztów w bibliotekach? Obecnie skonfigurowałem moje profilowanie w ten sposób:

kabała:

ghc-prof-options:    -O2
-threaded
-fexcess-precision
-fprof-auto
-rtsopts
"-with-rtsopts=-N -p -s -h -i0.1"

exec:

# cabal sandbox init
# cabal install --enable-library-profiling --enable-executable-profiling
# cabal configure --enable-library-profiling --enable-executable-profiling
# cabal run

To działa i tworzy oczekiwane .prof plik, .hp plik i podsumowanie po zakończeniu programu.

Problem polega na tym, że .prof plik nie zawiera niczego, co nie należy do bieżącego projektu. Domyślam się, że prawdopodobnie istnieje opcja, która umieści centra kosztów w zewnętrznym kodzie biblioteki?

Odpowiedzi:

4 dla odpowiedzi № 1

Domyślam się, że prawdopodobnie istnieje opcja, która umieści centra kosztów w zewnętrznym kodzie biblioteki?

No nie domyślnie. Musisz dodać miejsca powstawania kosztów podczas kompilacji zależności. Możesz jednak dodać -fprof-auto do ghc opcje podczas cabal install:

$ cabal sandbox init $ cabal install --ghc-option = -fprof-auto -p --enable-executable-profiling

Przykład

Przykład użycia kod z tego pytania, gdzie kod z pytania jest zawarty w SO.hs:

$ cabal sandbox init $ cabal install vector -p--ghc-options = -fprof-auto $ cabal exec - ghc --make SO.hs -prof -fprof-auto -O2 $ ./SO / usr / share / dict / words + RTS -s -p $ cat SO.prof Wt 2 grudnia 15:01 2014 Raport profilowania czasu i alokacji (końcowy)  Test + RTS -s -p -RTS / usr / share / dict / words  całkowity czas = 0,70 s (698 ticków @ 1000 us, 1 procesor) całkowity alok = 618 372 952 bajtów (z wyłączeniem kosztów ogólnych profilowania)  MODUŁ CENTRUM KOSZTÓW% czasu% alokacji  letterCount Main 40.3 24.3 letterCount.letters1 Główny 13.2 18.2 basicUnsafeWrite Data.Vector.Primitive.Mutable 10.0 12.1 basicUnsafeWrite Data.Vector.Unboxed.Base 7.2 7.3 basicUnsafeRead Data.Vector.Primitive.Mutable 5.4 4.9 >> = Data.Vector.Fusion.Util 5.0 13.4 basicUnsafeIndexM Data.Vector.Unboxed.Base 4.9 0.0 basicUnsafeIndexM Data.Vector.Primitive 2.7 4.9 basicUnsafeIndexM Data.Vector.Unboxed.Base 2.3 0.0 letterCount.letters1. Główne 2.0 2.4 >> = Data.Vector.Fusion.Util 1.9 6.1 basicUnsafeWrite Data.Vector.Unboxed.Base 1.7 0.0 letterCount. Główne 1.3 2.4 readByteArray # Data.Primitive.Types 0.3 2.4 basicUnsafeNew Data.Vector.Primitive.Mutable 0.0 1.2   osoba odziedziczona MODUŁ COST CENTER nr. wpisy% time% alloc% time% alloc  MAIN MAIN 72 0 0,0 0,0 100,0 100,0 main Main 145 0 0,1 0,2 99,9 100,0 main.counts 148 148 0,0 0,0 99,3 99,6 letterCount Main 149 1 40,3 24,3 99,3 99,6 basicUnsafeFreeze Data.Vector.Unboxed.Base 257 1 0.0 0.0 0.0 0.0 prymitywny Control.Monad.Primitive 259 1 0.0 0.0 0.0 0.0 basicUnsafeFreeze Data.Vector.Primitive 258 1 0.0 0.0 0.0 0.0 letterCount. Główne 256 938848 1.3 2.4 1.3 2.4 basicUnsafeWrite Data.Vector.Unboxed.Base 252 938848 1.3 0.0 5.0 6.1 basicUnsafeWrite Data.Vector.Primitive.Mutable 253 938848 3.7 6.1 3.7 6.1 writeByteArray # Data.Primitive.Types 255 938848 0,0 0,0 0,0 prymitywny Control.Monad.Primitive 254 938848 0,0 0,0 0,0 0,0 basicUnsafeRead Data.Vector.Unboxed.Base 248 938848 0,7 0,0 6,6 7,3 basicUnsafeRead Data.Vector.Primitive.Mutable 249 938848 5,4 4,9 5,9 7.3 readByteArray # Data.Primitive.Types 251 938848 0,3 2,4 0,3 2.4 prymitywny Control.Monad.Primitive 250 938848 0,1 0,0 0,1 0,0 >> = Data.Vector.Fusion.Util 243 938848 0,0 0,0 0,0 0,0 basicUnsafeIndexM Data.Vector.Unboxed.Base 242 938848 0,0 0,0 0,0 0,0 basicUnsafeIndexM Data.Vector.Unboxed.Base 237 938848 4,9 0,0 11,7 10,9 >> = Data.Vector.Fusion.Util 247 938848 1.9 6.1 1.9 6.1 basicUnsafeIndexM Data.Vector.Unboxed.Base 238 938848 2,3 0,0 5,0 4,9 basicUnsafeIndexM Data.Vector.Primitive 239 938848 2,7 4,9 2,7 4,9 indexByteArray # Data.Primitive.Types 240 938848 0,0 0,0 0,0 >> = Data.Vector.Fusion.Util 236 938849 3.4 7.3 3.4 7.3 unId Data.Vector.Fusion.Util 235 938849 0,0 0,0 0,0 0,0 basicLength Data.Vector.Unboxed.Base 234 1 0.0 0.0 0.0 0.0 basicLength Data.Vector.Primitive.Mutable 233 1 0.0 0.0 0.0 0.0 basicUnsafeCopy Data.Vector.Unboxed.Base 222 1 0.0 0.0 0.0 0.0 basicUnsafeCopy Data.Vector.Primitive 223 1 0.0 0.0 0.0 0.0 unI # Data.Primitive.ByteArray 226 3 0.0 0.0 0.0 0.0 basicLength Data.Vector.Unboxed.Base 214 1 0.0 0.0 0.0 0.0 basicLength Data.Vector.Primitive 215 1 0.0 0.0 0.0 0.0 basicUnsafeNew Data.Vector.Unboxed.Base 212 1 0.0 0.0 0.0 0.0 prymitywny Control.Monad.Primitive 220 1 0.0 0.0 0.0 0.0 basicUnsafeNew Data.Vector.Primitive.Mutable 216 1 0.0 0.0 0.0 0.0 sizeOf Data.Primitive 217 1 0.0 0.0 0.0 0.0 sizeOf # Data.Primitive.Types 218 1 0.0 0.0 0.0 0.0 unI # Data.Primitive.Types 219 1 0.0 0.0 0.0 0.0 basicLength Data.Vector.Unboxed.Base 211 1 0.0 0.0 0.0 0.0 letterCount.len Main 178 1 0,0 0,0 0,0 0,0 letterCount.letters1 Główny 177 1 13,2 18,2 30,9 41,3 basicUnsafeFreeze Data.Vector.Unboxed.Base 204 1 0.0 0.0 0.0 0.0 basicUnsafeFreeze Data.Vector.Unboxed.Base 210 1 0,0 0,0 0,0 0,0 prymitywny Control.Monad.Primitive 207 1 0.0 0.0 0.0 0.0 basicUnsafeFreeze Data.Vector.Primitive 206 1 0.0 0.0 0.0 0.0 basicUnsafeFreeze Data.Vector.Unboxed.Base 205 1 0,0 0,0 0,0 0,0 basicUnsafeFreeze Data.Vector.Primitive 208 0 0,0 0,0 0,0 0,0 basicUnsafeSlice Data.Vector.Unboxed.Base 200 1 0.0 0.0 0.0 0.0 basicUnsafeSlice Data.Vector.Unboxed.Base 203 1 0.0 0.0 0.0 0.0 basicUnsafeSlice Data.Vector.Unboxed.Base 201 1 0.0 0.0 0.0 0.0 basicUnsafeSlice Data.Vector.Primitive.Mutable 202 1 0.0 0.0 0.0 0.0 basicUnsafeWrite Data.Vector.Unboxed.Base 193 938848 7,2 7,3 14,2 13,4 basicUnsafeWrite Data.Vector.Unboxed.Base 198 938848 0,0 0,0 0,0 0,0 basicUnsafeWrite Data.Vector.Unboxed.Base 194 938848 0,4 0,0 7,0 6.1 basicUnsafeWrite Data.Vector.Primitive.Mutable 195 938848 6.3 6.1 6.6 6.1 writeByteArray # Data.Primitive.Types 197 938848 0,3 0,0 0,3 prymitywny Control.Monad.Primitive 196 938848 0,0 0,0 0,0 0,0 letterCount.letters1. Main 192 938848 2.0 2.4 2.0 2.4 >> = Data.Vector.Fusion.Util 191 938848 1.6 6.1 1.6 6.1 unId Data.Vector.Fusion.Util 190 938849 0,0 0,0 0,0 0,0 upperBound Data.Vector.Fusion.Stream.Size 180 1 0.0 0.0 0.0 0.0 basicUnsafeNew Data.Vector.Unboxed.Base 179 1 0.0 0.0 0.0 1.2 basicUnsafeNew Data.Vector.Unboxed.Base 189 1 0.0 0.0 0.0 0.0 prymitywny Control.Monad.Primitive 187 1 0.0 0.0 0.0 0.0 basicUnsafeNew Data.Vector.Primitive.Mutable 182 1 0.0 0.0 0.0 0.0 basicUnsafeNew Data.Vector.Unboxed.Base 181 1 0.0 0.0 0.0 1.2 basicUnsafeNew Data.Vector.Primitive.Mutable 183 0 0.0 1.2 0.0 1.2 sizeOf Data.Primitive 184 1 0.0 0.0 0.0 0.0 sizeOf # Data.Primitive.Types 185 1 0.0 0.0 0.0 0.0 unI # Data.Primitive.Types 186 1 0.0 0.0 0.0 0.0 drukujKwoty Główne 146 1 0,4 0,2 0,4 0,2 basicUnsafeIndexM Data.Vector.Unboxed.Base 266 256 0,0 0,0 0,0 0,0 basicUnsafeIndexM Data.Vector.Primitive 267 0 0,0 0,0 0,0 0,0 indexByteArray # Data.Primitive.Types 268 256 0,0 0,0 0,0 0,0 basicUnsafeIndexM Data.Vector.Primitive 265 256 0,0 0,0 0,0 0,0 >> = Data.Vector.Fusion.Util 264 256 0,0 0,0 0,0 0,0 unId Data.Vector.Fusion.Util 263 256 0,0 0,0 0,0 0,0 basicLength Data.Vector.Unboxed.Base 262 1 0.0 0.0 0.0 0.0 basicLength Data.Vector.Primitive 261 1 0.0 0.0 0.0 0.0 CAF Main 143 0 0,0 0,0 0,0 0,0 main Main 144 1 0,0 0,0 0,0 0,0 main.counts Main 150 0 0.0 0.0 0.0 0.0 letterCount Main 151 0 0,0 0,0 0,0 0,0 basicUnsafeIndexM Data.Vector.Unboxed.Base 244 0 0,0 0,0 0,0 0,0 >> = Data.Vector.Fusion.Util 245 0 0.0 0.0 0.0 0.0 basicUnsafeIndexM Data.Vector.Unboxed.Base 246 0 0,0 0,0 0,0 0,0 prymitywny Control.Monad.Primitive 224 1 0.0 0.0 0.0 0.0 basicUnsafeFreeze Data.Vector.Unboxed.Base 173 1 0.0 0.0 0.0 0.0 prymitywny Control.Monad.Primitive 175 1 0.0 0.0 0.0 0.0 basicUnsafeFreeze Data.Vector.Primitive 174 1 0,0 0,0 0,0 0,0 basicUnsafeSlice Data.Vector.Unboxed.Base 171 1 0.0 0.0 0.0 0.0 basicUnsafeSlice Data.Vector.Primitive.Mutable 172 1 0.0 0.0 0.0 0.0 basicUnsafeWrite Data.Vector.Unboxed.Base 167 256 0,0 0,0 0,0 0,0 basicUnsafeWrite Data.Vector.Primitive.Mutable 168 256 0,0 0,0 0,0 0,0 writeByteArray # Data.Primitive.Types 170 256 0,0 0,0 0,0 prymitywny Control.Monad.Primitive 169 256 0,0 0,0 0,0 0,0 >> = Data.Vector.Fusion.Util 165 256 0,0 0,0 0,0 0,0 unId Data.Vector.Fusion.Util 164 257 0,0 0,0 0,0 0,0 basicUnsafeNew Data.Vector.Unboxed.Base 156 1 0.0 0.0 0.0 0.0 prymitywny Control.Monad.Primitive 162 1 0.0 0.0 0.0 0.0 basicUnsafeNew Data.Vector.Primitive.Mutable 157 1 0.0 0.0 0.0 0.0 sizeOf Data.Primitive 158 1 0,0 0,0 0,0 0,0 sizeOf # Data.Primitive.Types 159 1 0.0 0.0 0.0 0.0 unI # Data.Primitive.Types 160 1 0,0 0,0 0,0 0,0 upperBound Data.Vector.Fusion.Stream.Size 153 1 0.0 0.0 0.0 0.0 elemseq Data.Vector.Unboxed.Base 152 1 0,0 0,0 0,0 0,0 printCounts Main 147 0 0,0 0,0 0,0 0,0 CAF Data.Vector.Internal.Check 142 0 0.0 0.0 0.0 0.0 doBoundsChecks Data.Vector.Internal.Check 213 1 0.0 0.0 0.0 0.0 doUnsafeChecks Data.Vector.Internal.Check 155 1 ​​0.0 0.0 0.0 0.0 doInternalChecks Data.Vector.Internal.Check 154 1 0.0 0.0 0.0 0.0 CAF Data.Vector.Fusion.Util 141 0 0,0 0,0 0,0 0,0 return Data.Vector.Fusion.Util 241 1 0.0 0.0 0.0 0.0 Zwróć Dane.Vektor.Fusion.Uil 166 1 0,0 0,0 0,0 0,0 CAF Data.Vector.Unboxed.Base 136 0 0,0 0,0 0,0 0,0 basicUnsafeCopy Data.Vector.Unboxed.Base 227 0 0.0 0.0 0.0 0.0 basicUnsafeCopy Data.Vector.Primitive 228 0 0,0 0,0 0,0 0,0 basicUnsafeCopy.sz Data.Vector.Primitive 229 1 0.0 0.0 0.0 0.0 sizeOf Data.Primitive 230 1 0,0 0,0 0,0 0,0 sizeOf # Data.Primitive.Types 231 1 0.0 0.0 0.0 0.0 unI # Data.Primitive.Types 232 1 0,0 0,0 0,0 0,0 CAF Data.Primitive.MachDeps 128 0 0,0 0,0 0,0 0,0 sIZEOF_INT Data.Primitive.MachDeps 161 1 0,0 0,0 0,0 0,0 CAF Text.Printf 118 0 0,0 0,0 0,0 0,0 CAF GHC.Conc.Signal 112 0 0,0 0,0 0,0 0,0 CAF GHC.IO.Handle.FD 109 0 0,1 0,0 0,1 0,0 CAF GHC.IO.Encoding 99 0 0,0 0,0 0,0 0,0 CAF GHC.IO.Encoding.Iconv 98 0 0,0 0,0 0,0 0,0 CAF GHC.IO.FD 95 0 0,0 0,0 0,0 0,0

Niestety, ty nie mogę stwierdzić --ghc-option=… jako flaga w zależnościach.


0 dla odpowiedzi nr 2

Potrzebujesz również -prof.

Przewodnik dla użytkowników GHC mówi „Istnieje kilka innych opcji kompilacji związanych z profilowaniem. Użyj ich oprócz -prof. Nie muszą one być konsekwentnie używane dla wszystkich modułów w programie.

"