<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Profiling</id>
	<title>Profiling - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Profiling"/>
	<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Profiling&amp;action=history"/>
	<updated>2026-05-02T19:13:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.7</generator>
	<entry>
		<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Profiling&amp;diff=850&amp;oldid=prev</id>
		<title>Weber: Created page with &quot;  Category:Isis / Slang ====== profile module ======  The '''profile''' module analyses function run-times ([http://www.jedsoft.org/slang/doc/html/slang-21.html SLang Doc]...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Profiling&amp;diff=850&amp;oldid=prev"/>
		<updated>2018-04-11T15:00:40Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;  &lt;a href=&quot;/wiki/index.php/Category:Isis_/_Slang&quot; title=&quot;Category:Isis / Slang&quot;&gt;Category:Isis / Slang&lt;/a&gt; ====== profile module ======  The &amp;#039;&amp;#039;&amp;#039;profile&amp;#039;&amp;#039;&amp;#039; module analyses function run-times ([http://www.jedsoft.org/slang/doc/html/slang-21.html SLang Doc]...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Isis / Slang]]&lt;br /&gt;
====== profile module ======&lt;br /&gt;
&lt;br /&gt;
The '''profile''' module analyses function run-times ([http://www.jedsoft.org/slang/doc/html/slang-21.html SLang Doc]). It can be used to analyse/profile the run-time of functions and function-calls within&lt;br /&gt;
of self-defined functions or functions added to SLang by other modules, i.e., intrinsic SLang functions are excluded.&lt;br /&gt;
&lt;br /&gt;
As the documentary has yet to be continued, here some informations:&lt;br /&gt;
* The profile module is loaded with isis&amp;gt; require(&amp;quot;profile&amp;quot;);&lt;br /&gt;
* It adds the following functions: profile_begin, profile_calibrate, profile_end, profile_off, profile_on, profile_report&lt;br /&gt;
* Before including/loading any other modules/functions isis&amp;gt; profile_on(); has to be executed!&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Under /home/falkner/Public/isis/profile there are example files. In the '''profile_function.sl''' there are some definitions of dummy functions, which will be profiled. There are several ''inner_fnct''s, which are called by and ''outer_fnct'' in different ways to show run-time differences. The '''profile_example.sl''' script shows how to actually use the '''profile''' module with an basic example. In the end a '''profile_report.txt''' is produced, which shows the profile result. In the first column (__#function__) all functions are listed, which where called between &amp;quot;profile_begin&amp;quot; and &amp;quot;profile_end&amp;quot;. __ncalls__ represents how often each function was called and __ms/call__ is the corresponding time in milliseconds per call. __totalselfms__/__totalsecs__ is the total time (~ncalls*time/call) in msecs or secs, respectively. Note that the run-time of the ''outer_fnct'' is already subtracted by the run-time of its subfunctions! __Function__ gives the number of function calls within this function.&lt;br /&gt;
&lt;br /&gt;
Please note that all ''inner_fnct'' are basically calculating the same, but their run-time differs a lot. Avoiding loops and utilize that isis is able to perform array-operations is the fastest. But even if loops cannot be avoided, the choice how to write them can make a big difference. The most time consuming step here is to extend an array by one array-element in each step of the loop. &lt;br /&gt;
&lt;br /&gt;
'''profile_function.sl'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define inner_fnct1( x ){   return sqrt(sin(sqr(x))) mod 10; }&lt;br /&gt;
define inner_fnct3( x ){   return sqrt(sin(sqr(x))) mod 10; }&lt;br /&gt;
define inner_fnct4( x ){   return sqrt(sin(sqr(x))) mod 10; }&lt;br /&gt;
define inner_fnct5( x ){   return sqrt(sin(sqr(x))) mod 10; }&lt;br /&gt;
&lt;br /&gt;
define inner_fnct2( x ){&lt;br /&gt;
  variable y = _typeof(x)[length(x)];&lt;br /&gt;
  _for $1 ( 0, length(x)-1 ){&lt;br /&gt;
    y[$1] = sqrt(sin(sqr(x[$1]))) mod 10;&lt;br /&gt;
  }&lt;br /&gt;
  return y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define outer_fnct(x){&lt;br /&gt;
  variable y1 = inner_fnct1(x);&lt;br /&gt;
  variable y2 = inner_fnct2(x);&lt;br /&gt;
&lt;br /&gt;
  variable y3 = Double_Type[0];&lt;br /&gt;
  foreach $1 ( x ){&lt;br /&gt;
    y3 = [y3, inner_fnct3($1)];&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  variable y4 = Double_Type[length(x)];&lt;br /&gt;
  _for $1 ( 0, length(x)-1 ){&lt;br /&gt;
    y4[$1] = inner_fnct4($1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  variable y5 = Double_Type[length(x)];&lt;br /&gt;
  for( $1=0; $1&amp;lt;length(x); $1++ ){&lt;br /&gt;
    y5[$1] = inner_fnct5($1);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''profile_example.sl'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% The profile module has to be included and enabled&lt;br /&gt;
%%  before any other module&lt;br /&gt;
require(&amp;quot;profile&amp;quot;);&lt;br /&gt;
profile_on();&lt;br /&gt;
&lt;br /&gt;
%% after that other modules and scripts can be loaded&lt;br /&gt;
require(&amp;quot;isisscripts&amp;quot;);&lt;br /&gt;
()=evalfile(&amp;quot;profile_function.sl&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
variable x = [0:1e5];&lt;br /&gt;
&lt;br /&gt;
%% Before calling the funktion you want to profile start the profiling&lt;br /&gt;
%% The 1 is an optional argument which adds line-by-line profiling&lt;br /&gt;
profile_begin(1);&lt;br /&gt;
outer_fnct(x);&lt;br /&gt;
&lt;br /&gt;
%% Afterwards the profiling has to be ended and a report can be written:&lt;br /&gt;
profile_end();&lt;br /&gt;
profile_report(&amp;quot;profile_report.txt&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
%% The profile module can be switch off by:&lt;br /&gt;
profile_off();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''profile_report.txt'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#----------------------------------------------------------------&lt;br /&gt;
#                  Function Call Profile Report&lt;br /&gt;
#----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
#function                 ncalls      ms/call  totalselfms    totalsecs Function File&lt;br /&gt;
inner_fnct3               100000       0.0019     185.7670       0.1858       0       0 ./profile_function.sl&lt;br /&gt;
inner_fnct5               100000       0.0013     129.8830       0.1299       0       0 ./profile_function.sl&lt;br /&gt;
inner_fnct4               100000       0.0013     127.6480       0.1276       0       0 ./profile_function.sl&lt;br /&gt;
inner_fnct2                    1      74.1160      74.1160       0.0741       0       0 ./profile_function.sl&lt;br /&gt;
inner_fnct1                    1      15.0210      15.0210       0.0150       0       0 ./profile_function.sl&lt;br /&gt;
outer_fnct                     1       0.4360       0.4360       0.0004  300002       0 ./profile_function.sl&lt;br /&gt;
&lt;br /&gt;
#----------------------------------------------------------------&lt;br /&gt;
#                  Line by Line Profile Report&lt;br /&gt;
#----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
#ncalls      ms/call totalselfms     totalsecs  Fcalls   Scalls File:line&lt;br /&gt;
      1      0.44400      0.00800      0.00044  600006       0 ./profile_example.sl:15&lt;br /&gt;
      1      0.00000      0.00000      0.00000       0       0 ./profile_example.sl:18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Weber</name></author>
	</entry>
</feed>