रूपरेखा ढेर 1.0.0 के साथ बनाता है और नए
सक्षम रूपरेखा के साथ बनाने के लिए:
stack build --profile
आप stack clean
पहले, लेकिन this should be fixed in Stack 1.5.0 चलाने के लिए आवश्यकता हो सकती है।
प्रोफ़ाइल करने के लिए:
stack exec -- <your program> +RTS <profiling options>
जहां <profiling options>
के लिए आप स्मृति रूपरेखा के लिए या समय रूपरेखा के लिए -p
-h
चाहते हो सकता है। समय प्रोफाइलिंग के लिए, प्रोफ़ाइल ./<your program>.prof
में दिखाई देती है, और स्मृति प्रोफाइलिंग के लिए, प्रोफ़ाइल ./<your program>.hp
में दिखाई देती है।
अधिक प्रोफ़ाइल विकल्पों के लिए GHC profiling documentation देखें।
रूपरेखा 1.0.0 से पहले ढेर संस्करणों के साथ बनाता है (2015 से यानी)
रूपरेखा के साथ निर्माण करने के लिए सक्षम होना चाहिए: ढेर 1.0 के लिए
stack exec -- <your program> +RTS <profiling options>
उदाहरण:
stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts"
प्रोफ़ाइल की। 0 और नए
मान लें कि आपके पास test
वाई नामक एक पैकेज है वें एक भी निष्पादन योग्य test
main
यहाँ से परिभाषित किया गया:
module Main where
main :: IO()
main = do
print $ foo 0
foo :: Int -> Int
foo x = fooSub (x+1)
where
fooSub x = bar (x+1)
bar :: Int -> Int
bar x = barSub (x+1)
where
barSub x = barSubSub (x+1)
where
barSubSub x = x+1
तो stack build --profile && stack exec -- test +RTS -p
कर एक फाइल ./test.prof
जो
individual inherited
COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc
[... many lines omitted ...]
main Main src/Main.hs:(4,1)-(5,15) 97 0 0.0 0.0 0.0 0.0
foo Main src/Main.hs:(8,1)-(10,24) 98 1 0.0 0.0 0.0 0.0
foo.fooSub Main src/Main.hs:10:5-24 99 1 0.0 0.0 0.0 0.0
bar Main src/Main.hs:(13,1)-(17,46) 100 1 0.0 0.0 0.0 0.0
bar.barSub Main src/Main.hs:(15,5)-(17,46) 101 1 0.0 0.0 0.0 0.0
bar.barSub.barSubSub Main src/Main.hs:17:9-46 102 1 0.0 0.0 0.0 0.0
main Main src/Main.hs:(4,1)-(5,15) 95 0 0.0 20.5 0.0 20.5
Ie शामिल उत्पादन करेगा, सभी परिभाषाओं के लिए रूपरेखा की जानकारी, where
में स्थानीय परिभाषाओं सहित है खंड।
आप केवल उच्च-स्तरीय परिभाषाओं प्रोफ़ाइल करना चाहते हैं, तो आप साथ GHC विकल्प -fprof-auto-top
बजाय का निर्माण कर सकते हैं: stack build --profile --ghc-options=-fprof-auto-top && stack exec -- test +RTS -p
कर एक ./test.prof
जो
individual inherited
COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc
[... many lines omitted ...]
main Main src/Main.hs:(4,1)-(5,15) 97 0 0.0 0.0 0.0 0.0
foo Main src/Main.hs:(8,1)-(10,24) 98 1 0.0 0.0 0.0 0.0
bar Main src/Main.hs:(13,1)-(17,46) 99 1 0.0 0.0 0.0 0.0
main Main src/Main.hs:(4,1)-(5,15) 95 0 0.0 20.5 0.0 20.5
बजाय
शामिल पैदा करता है।
अंत में, ध्यान दें कि stack build --profile
भी स्टैक निशान पर बदल जाता है।आप, ताकि barSubSub x = error $ show x
कार्यक्रम को बदलते हैं तो stack build --profile && stack exec test
चल
test: 4
CallStack (from HasCallStack):
error, called at src/Main.hs:17:23 in main:Main
CallStack (from -prof):
Main.bar.barSub.barSubSub (src/Main.hs:17:9-36)
Main.bar.barSub (src/Main.hs:(15,5)-(17,36))
Main.bar (src/Main.hs:(13,1)-(17,36))
Main.foo.fooSub (src/Main.hs:10:5-24)
Main.foo (src/Main.hs:(8,1)-(10,24))
Main.main (src/Main.hs:(4,1)-(5,15))
Main.CAF:lvl8_r4Fc (<no location info>)
बहुत अच्छा उत्पादन करता है!
यह काम नहीं करता है। स्टैक निष्पादन का उपयोग करना मेरा-एक्सई + आरटीएस-पी दिखाता है निष्पादन योग्यों को संकलित नहीं किया गया है, और ऐसा करने का प्रयास करने से पता चलता है कि ld पुस्तकालयों के प्रोफाइल संस्करण नहीं ढूंढ सकते हैं। –
यह मेरे लिए काम करता है: 'स्टैक इंस्टॉल - सक्षम-निष्पादन योग्य-प्रोफाइलिंग - सक्षम-लाइब्रेरी-प्रोफाइलिंग --ghc-options = "- fprof-auto -rtsopts" ' – Dfr
बिल्ड के बाद इसे आप कैसे निष्पादित/प्रोफाइल करते हैं पूरा कर दिया है? –