DevelopmentProfiling: Unterschied zwischen den Versionen

Aus FHEMWiki
Keine Bearbeitungszusammenfassung
(→‎Profiling step-by-step: -> install mittels sudo apt-get hinzugefügt)
Zeile 5: Zeile 5:
== Profiling step-by-step ==
== Profiling step-by-step ==
You need [http://search.cpan.org/~timb/Devel-NYTProf-4.23/lib/Devel/NYTProf.pm Devel::NYTProf] from CPAN.
You need [http://search.cpan.org/~timb/Devel-NYTProf-4.23/lib/Devel/NYTProf.pm Devel::NYTProf] from CPAN.
Edit: Der CPAN Link ist defekt. Man kann alternativ installieren mittels
<code>sudo apt-get install libdevel-nytprof-perl</code>


Start <tt>fhem.pl</tt> as follows:
Start <tt>fhem.pl</tt> as follows:

Version vom 14. April 2017, 15:31 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.

Edit: Der CPAN Link ist defekt. Man kann alternativ installieren mittels 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.