2015-02-10 49 views
1

剖析我用gprof2dot來分析我的應用程序:隱藏的功能,長的描述,而與gprof2dot

./gprof2dot.py -f callgrind callgrind.out.x | dot -Tsvg -o output.svg

source

即便如此,它給了我美麗的圖形分析,在每個函數的名稱每個盒子都很長,並且遠遠超過屏幕尺寸。由於boost庫對模板的使用率很高。試想一下,在功能名稱中的一個:

std::reference_wrapper<boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_fsal_tag> > std::ref<boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_fsal_tag> >(boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_fsal_tag>&) 

有什麼辦法去掉名字空間和模板,甚至函數的參數,使其在圖形看起來更小?

PS。圖像非常大,我無法將其轉換爲png。我不知道你是否可以下載並打開這張10MB的圖片(link)。

+0

我的同情心。我打開了圖像,你說得對,它很瘋狂。更重要的是,大多數的盒子都不是你的。如果我需要找出如何加快我的代碼,我使用[*此方法*](http://stackoverflow.com/a/378024/23771)。如果你不知道你的代碼的哪一部分導致了它,那麼知道一些庫函數佔用了大部分時間是毫無意義的。 – 2015-02-10 16:53:27

+0

'callgrind.out.x'只是文本文件,每個函數的名字只存儲一次。您可以使用awk或perl逐行對其進行預處理。 – osgx 2015-03-03 07:32:48

+0

@Mike Dunlavey,你確定在這裏存在XY問題,你的可憐的人檔案器(或者如果你不喜歡這個名字,統計人員分析器)應該在這裏銷售嗎? (barej已經連接到他的問題中的同一個線程!!)你是否監視每個標籤爲'profiler'的問題? – osgx 2015-03-03 07:34:54

回答

1

./gprof2dot.py有兩個相關的選項:

-s, --strip   strip function parameters, template parameters, and 
         const modifiers from demangled C++ function names 
-w, --wrap   wrap function names 

我個人更喜歡-w,我仍然可以告訴模板分開。