trace2: add global counter mechanism
Add global counters mechanism to Trace2. The Trace2 counters mechanism adds the ability to create a set of global counter variables and an API to increment them efficiently. Counters can optionally report per-thread usage in addition to the sum across all threads. Counter events are emitted to the Trace2 logs when a thread exits and at process exit. Counters are an alternative to `data` and `data_json` events. Counters are useful when you want to measure something across the life of the process, when you don't want per-measurement events for performance reasons, when the data does not fit conveniently within a region, or when your control flow does not easily let you write the final total. For example, you might use this to report the number of calls to unzip() or the number of de-delta steps during a checkout. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8ad575646c
commit
81071626ba
@ -805,6 +805,37 @@ The "value" field may be an integer or a string.
|
||||
}
|
||||
------------
|
||||
|
||||
`"th_counter"`::
|
||||
This event logs the value of a counter variable in a thread.
|
||||
This event is generated when a thread exits for counters that
|
||||
requested per-thread events.
|
||||
+
|
||||
------------
|
||||
{
|
||||
"event":"th_counter",
|
||||
...
|
||||
"category":"my_category",
|
||||
"name":"my_counter",
|
||||
"count":23
|
||||
}
|
||||
------------
|
||||
|
||||
`"counter"`::
|
||||
This event logs the value of a counter variable across all threads.
|
||||
This event is generated when the process exits. The total value
|
||||
reported here is the sum across all threads.
|
||||
+
|
||||
------------
|
||||
{
|
||||
"event":"counter",
|
||||
...
|
||||
"category":"my_category",
|
||||
"name":"my_counter",
|
||||
"count":23
|
||||
}
|
||||
------------
|
||||
|
||||
|
||||
== Example Trace2 API Usage
|
||||
|
||||
Here is a hypothetical usage of the Trace2 API showing the intended
|
||||
|
Reference in New Issue
Block a user