DevelopmentProfiling: Unterschied zwischen den Versionen

Aus FHEMWiki
(→‎Profiling step-by-step: -> install mittels sudo apt-get hinzugefügt)
K (→‎Profiling step-by-step: -> Link korrigiert)
Zeile 4: Zeile 4:


== 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/dist/Devel-NYTProf/ Devel::NYTProf] from CPAN.


Edit: Der CPAN Link ist defekt. Man kann alternativ installieren mittels
On Debian based systems install package "libdevel-nytprof-perl":
<code>sudo apt-get install libdevel-nytprof-perl</code>
<code>sudo apt-get install libdevel-nytprof-perl</code>


Zeile 22: Zeile 22:


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==


[[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:36 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?