Project

General

Profile

AnubisProfiling » History » Version 6

Caine -, 04/24/2008 10:02 PM
Some spelling corrections

1 6 Caine -
2
h1. Anubis Profiling
3
4 1 Anonymous
Profiling functionnalities have been added to Anubis 1.8.
5
6
7 6 Caine -
h2. Documentation
8 1 Anonymous
9 6 Caine -
To use them, you first have to compile your ADM with the profiling instructions, using *-profile* option into the command line. A good idea is to use the *-sc* option to, as it can help you to identify the different functions and their location into source code.
10
11
Once compiled, you just have to start your ADM with the [[VirtualMachine]]. At the end of the execution (you can use CTRL + C to end your ADM), the VM will output (on stderr) plain text information about profiling. On big software, that a good idea to redirect stderr to a file (using '2> filename' on command line).
12
13 1 Anonymous
Some options are available to format the output :
14
||-profile:csv ||Use CSV (Comma Separated Values) output insteed of plain text||
15
||-csv_sep:<sep> ||Allows to define a separator for CSV output (ex: '-csv_sep:;' to have a semi-colon insteed a comma)||
16
17
18 6 Caine -
h2. Examples
19
20
21
Plain text output for fibonnacci.anubis
22
23
Command line : _anbexec fib 29_
24
<pre>
25 1 Anonymous
*** PROFILING DATA ***
26
*** Full executing time = 10.362 s
27
Function fib() [offset = 541]:
28
   hits = 1
29
   time (excluding children) = 0.002 s (0.0%)
30
   max  (including children) = 10.361 s (100.0%)
31
Function fib() [offset = 173]:
32
   hits = 1664079
33
   time (excluding children) = 10.360 s (100.0%)
34
   max  (including children) = 10.360 s (100.0%)
35
Function +() [offset = 89]:
36
   hits = 1
37
   time (excluding children) = 0.000 s (0.0%)
38
   max  (including children) = 0.000 s (0.0%)
39 6 Caine -
</pre>
40 1 Anonymous
41 6 Caine -
CSV output for fibonnacci.anubis
42
43
Command line : _anbexec fib 29 --profile:csv_
44 1 Anonymous
||Function||Offset||Hits||Time (excl. children)||Time %||Max (inc. children)||Max %||
45
||fib||541||1||0.001657||0.0||10.623458||100.0||
46
||fib||173||1664079||10.621774||100.0||10.621774||100.0||
47
||+||89||1||0.000027||0.0||0.000027||0.0||
48
49 6 Caine -
50
h2. About Terminal Calls
51
52 1 Anonymous
Terminal calls can be a problem for profiling. 
53
54
First, they can't be representated by recursive calls because we can have an infinite succession of these calls.
55
56 6 Caine -
Other approach is to do a 'fake' return just before a [[TerminalCall]]. But resulting profiling information is not really usable because the calls arborescence is broken.
57 2 Anonymous
58 6 Caine -
So the choosen approach was to consider that all subsequent [[TerminalCalls]] made from a function are simply like if this was the same function. Helped by some examples, I will try to show you how it works.
59 2 Anonymous
60
61 6 Caine -
 1. [[TerminalCall]] used as loop
62 4 Anonymous
If a terminal call is used as a loop implementation, this strategy is really fine because the function will be seen as if it was called only once and its execution time will include all loop interations.
63 6 Caine -
 2. [[TerminalCall]] used as automate
64 3 Anonymous
For the automate, profiling data are incomplete but not so bad... Only the automate entry function will be seen, but its execution time will include all subsequent calls into the automate. So we can have the automate executing time, but not the details of the functions composing it.
65 6 Caine -
 3. Functions that are simply terminating by a [[TerminalCall]] to another function.
66
In this case, the second fonction will not be seen and it execution time will be include into its caller. So some fonction can never appear because the compiler have otimized its call to a [[TerminalCall]]. This is the _worse_ case because some functions were _hidden_.
67 1 Anonymous
68 3 Anonymous
Example:
69 6 Caine -
<pre>
70 3 Anonymous
global define
71
	One
72
	fib
73
  (                       
74
		List(String) args     
75
  ) =                     
76
  if args is              
77
     {
78
       [ ] then print("Usage: fib <interger>\n"), 
79
80
       [h . t] then 
81
					if string_to_integer(h) is
82
					{
83
						failure then print("Argument must be a integer.\n"),
84
						success(n) then print("Fib("+h+") =  " + fib(n) + "\n")
85
					}
86
     }.
87 6 Caine -
</pre>
88
  The _print()_ function will never appear on profiling data because it's always used as [[TerminalCall]] of the _fib()_ function. So its executing time will be included to the _fib()_ function.