js/src/devtools/vprof/readme.txt

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 The two files vprof.h and vprof.cpp implement a simple value-profiling mechanism. By including these two files in avmplus (or any other project), you can value profile data as you wish (currently integers).
michael@0 6
michael@0 7 Usage:
michael@0 8 #include "vprof.h" // in the source file you want to use it
michael@0 9
michael@0 10 _vprof (value);
michael@0 11
michael@0 12 At the end of the execution, for each probe you'll get the data associated with the probe, such as:
michael@0 13
michael@0 14 File line avg [min : max] total count
michael@0 15 ..\..\pcre\pcre_valid_utf8.cpp 182 50222.75916 [0 : 104947] 4036955604 80381
michael@0 16
michael@0 17 The probe is defined at line 182 of file pcre_vali_utf8.cpp. It was called 80381 times. The min value of the probe was 0 while its max was 10497 and its average was 50222.75916. The total sum of all values of the probe is 4036955604. Later, I plan to add more options on the spectrum of data among others.
michael@0 18
michael@0 19 A few typical uses
michael@0 20 ------------------
michael@0 21
michael@0 22 To see how many times a given function gets executed do:
michael@0 23
michael@0 24 void f()
michael@0 25 {
michael@0 26 _vprof(1);
michael@0 27 ...
michael@0 28 }
michael@0 29
michael@0 30 void f()
michael@0 31 {
michael@0 32 _vprof(1);
michael@0 33 ...
michael@0 34 if (...) {
michael@0 35 _vprof(1);
michael@0 36 ...
michael@0 37 } else {
michael@0 38 _vprof(1);
michael@0 39 ...
michael@0 40 }
michael@0 41 }
michael@0 42
michael@0 43 Here are a few examples of using the value-profiling utility:
michael@0 44
michael@0 45 _vprof (e);
michael@0 46 at the end of program execution, you'll get a dump of the source location of this probe,
michael@0 47 its min, max, average, the total sum of all instances of e, and the total number of times this probe was called.
michael@0 48
michael@0 49 _vprof (x > 0);
michael@0 50 shows how many times and what percentage of the cases x was > 0,
michael@0 51 that is the probablitiy that x > 0.
michael@0 52
michael@0 53 _vprof (n % 2 == 0);
michael@0 54 shows how many times n was an even number
michael@0 55 as well as th probablitiy of n being an even number.
michael@0 56
michael@0 57 _hprof (n, 4, 1000, 5000, 5001, 10000);
michael@0 58 gives you the histogram of n over the given 4 bucket boundaries:
michael@0 59 # cases < 1000
michael@0 60 # cases >= 1000 and < 5000
michael@0 61 # cases >= 5000 and < 5001
michael@0 62 # cases >= 5001 and < 10000
michael@0 63 # cases >= 10000
michael@0 64
michael@0 65 _nvprof ("event name", value);
michael@0 66 all instances with the same name are merged
michael@0 67 so, you can call _vprof with the same event name at difference places
michael@0 68
michael@0 69 _vprof (e, myProbe);
michael@0 70 value profile e and call myProbe (void* vprofID) at the profiling point.
michael@0 71 inside the probe, the client has the predefined variables:
michael@0 72 _VAL, _COUNT, _SUM, _MIN, _MAX, and the general purpose registers
michael@0 73 _IVAR1, ..., IVAR4 general integer registrs
michael@0 74 _I64VAR1, ..., I64VAR4 general integer64 registrs
michael@0 75 _DVAR1, ..., _DVAR4 general double registers
michael@0 76 _GENPTR a generic pointer that can be used by the client
michael@0 77 the number of registers can be changed in vprof.h
michael@0 78
michael@0 79 Named Events
michael@0 80 ------------
michael@0 81 _nvprof ("event name", value);
michael@0 82 all instances with the same name are merged
michael@0 83 so, you can call _vprof with the same event name at difference places
michael@0 84
michael@0 85
michael@0 86 Custom Probes
michael@0 87 --------------
michael@0 88 You can call your own custom probe at the profiling point.
michael@0 89 _vprof (v, myProbe);
michael@0 90 value profile v and call myProbe (void* vprofID) at the profiling point
michael@0 91 inside the probe, the client has the predefined variables:
michael@0 92 _VAL, _COUNT, _SUM, _MIN, _MAX, and the general purpose registers
michael@0 93 _IVAR1, ..., IVAR4 general integer registrs
michael@0 94 _I64VAR1, ..., I64VAR4 general integer64 registrs
michael@0 95 _DVAR1, ..., _DVAR4 general double registers
michael@0 96 the number of registers can be changed in vprof.h
michael@0 97 _GENPTR a generic pointer that can be used for almost anything

mercurial