1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/devtools/vprof/readme.txt Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +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). 1.9 + 1.10 +Usage: 1.11 +#include "vprof.h" // in the source file you want to use it 1.12 + 1.13 +_vprof (value); 1.14 + 1.15 +At the end of the execution, for each probe you'll get the data associated with the probe, such as: 1.16 + 1.17 +File line avg [min : max] total count 1.18 +..\..\pcre\pcre_valid_utf8.cpp 182 50222.75916 [0 : 104947] 4036955604 80381 1.19 + 1.20 +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. 1.21 + 1.22 +A few typical uses 1.23 +------------------ 1.24 + 1.25 +To see how many times a given function gets executed do: 1.26 + 1.27 +void f() 1.28 +{ 1.29 + _vprof(1); 1.30 + ... 1.31 +} 1.32 + 1.33 +void f() 1.34 +{ 1.35 + _vprof(1); 1.36 + ... 1.37 + if (...) { 1.38 + _vprof(1); 1.39 + ... 1.40 + } else { 1.41 + _vprof(1); 1.42 + ... 1.43 + } 1.44 +} 1.45 + 1.46 +Here are a few examples of using the value-profiling utility: 1.47 + 1.48 + _vprof (e); 1.49 + at the end of program execution, you'll get a dump of the source location of this probe, 1.50 + its min, max, average, the total sum of all instances of e, and the total number of times this probe was called. 1.51 + 1.52 + _vprof (x > 0); 1.53 + shows how many times and what percentage of the cases x was > 0, 1.54 + that is the probablitiy that x > 0. 1.55 + 1.56 + _vprof (n % 2 == 0); 1.57 + shows how many times n was an even number 1.58 + as well as th probablitiy of n being an even number. 1.59 + 1.60 + _hprof (n, 4, 1000, 5000, 5001, 10000); 1.61 + gives you the histogram of n over the given 4 bucket boundaries: 1.62 + # cases < 1000 1.63 + # cases >= 1000 and < 5000 1.64 + # cases >= 5000 and < 5001 1.65 + # cases >= 5001 and < 10000 1.66 + # cases >= 10000 1.67 + 1.68 + _nvprof ("event name", value); 1.69 + all instances with the same name are merged 1.70 + so, you can call _vprof with the same event name at difference places 1.71 + 1.72 + _vprof (e, myProbe); 1.73 + value profile e and call myProbe (void* vprofID) at the profiling point. 1.74 + inside the probe, the client has the predefined variables: 1.75 + _VAL, _COUNT, _SUM, _MIN, _MAX, and the general purpose registers 1.76 + _IVAR1, ..., IVAR4 general integer registrs 1.77 + _I64VAR1, ..., I64VAR4 general integer64 registrs 1.78 + _DVAR1, ..., _DVAR4 general double registers 1.79 + _GENPTR a generic pointer that can be used by the client 1.80 + the number of registers can be changed in vprof.h 1.81 + 1.82 +Named Events 1.83 +------------ 1.84 +_nvprof ("event name", value); 1.85 + all instances with the same name are merged 1.86 + so, you can call _vprof with the same event name at difference places 1.87 + 1.88 + 1.89 +Custom Probes 1.90 +-------------- 1.91 +You can call your own custom probe at the profiling point. 1.92 +_vprof (v, myProbe); 1.93 + value profile v and call myProbe (void* vprofID) at the profiling point 1.94 + inside the probe, the client has the predefined variables: 1.95 + _VAL, _COUNT, _SUM, _MIN, _MAX, and the general purpose registers 1.96 + _IVAR1, ..., IVAR4 general integer registrs 1.97 + _I64VAR1, ..., I64VAR4 general integer64 registrs 1.98 + _DVAR1, ..., _DVAR4 general double registers 1.99 + the number of registers can be changed in vprof.h 1.100 + _GENPTR a generic pointer that can be used for almost anything