DevelopmentProfiling: Unterschied zwischen den Versionen

Aus FHEMWiki
Zur Navigation springen Zur Suche springen
K (→‎Profiling step-by-step: -> Link korrigiert)
K (Typo)
Zeile 23: Zeile 23:
This produces a subfolder names <tt>nytprof.</tt> Direct your browser to file <tt>index.html</tt> therein. You will get a bunch of information how FHEM spends its time.
This produces a subfolder names <tt>nytprof.</tt> Direct your browser to file <tt>index.html</tt> therein. You will get a bunch of information how FHEM spends its time.
==Links==
==Links==
official perlfaq: [http://learn.perl.org/faq/perlfaq3.html#How-do-I-profile-my-Perl-programs How do I profile my Perl programs?]


[[Kategorie:Development]]
[[Kategorie:Development]]
official perlfaq: [http://learn.perl.org/faq/perlfaq3.html#How-do-I-profile-my-Perl-programs How do I profile my Perl programs?]

Version vom 18. April 2017, 08:49 Uhr

Profiling FHEM

What is profiling?

In software engineering, profiling ("program profiling", "software profiling") is a form of dynamic program analysis that measures, for example, the space (memory) or time complexity of a program, the usage of particular instructions, or frequency and duration of function calls. The most common use of profiling information is to aid program optimization. (from Wikipedia)

Profiling step-by-step

You need Devel::NYTProf from CPAN.

On Debian based systems install package "libdevel-nytprof-perl": sudo apt-get install libdevel-nytprof-perl

Start fhem.pl as follows:

perl -d:NYTProf /opt/fhem/fhem.pl /opt/fhem/conf/fhem.conf

Let it run for a while and then shut down FHEM.

You will find a bunch of nytprof.out files in /opt/fhem. nytprof.out contains the profile for the parent process and each nytprof.out.<pid> file contains the profile for a child process forked by the parent process. Not nytprof.out but the largest nytprof.out.<pid> file contains the profile of the master process since FHEM does an initial fork when it is ready.

You transfer the profile of the master process into something human-readable by issueing the command

nytprofhtml -f nytprof.out.<pid>

This produces a subfolder names nytprof. Direct your browser to file index.html therein. You will get a bunch of information how FHEM spends its time.

Links

official perlfaq: How do I profile my Perl programs?