Commit ec1e3dc0 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl

Merge branch 'master' into 'master'

move error handling to a separate section

See merge request !2
parents 37bfbfe4 f0d08ac9
Pipeline #68200 failed with stage
in 21 seconds
......@@ -122,20 +122,13 @@ b) instantiate a ``ftimer_t`` object at the top of the main function or wherever
ftimer_t *timer;
timer = ftimings_create();
c) register ftimings error handler with timer name
.. code-block:: C
const char *timername = "mytimer";
ftimings_register_error_handler(timer, error_handler, (void*) timername);
d) enable the timer
c) enable the timer
.. code-block:: C
ftimings_enable(timer);
e) start/stop the timer: wrap the sections of your code for timing
d) start/stop the timer: wrap the sections of your code for timing
.. code-block:: C
......@@ -143,13 +136,13 @@ e) start/stop the timer: wrap the sections of your code for timing
[…]
ftimings_stop(timer, "section1");
f) print the measured times
e) print the measured times
.. code-block:: C
ftimings_print(timer, 0.0);
g) destroy the ``ftimer_t`` object
f) destroy the ``ftimer_t`` object
.. code-block:: C
......@@ -333,6 +326,24 @@ Thresholds
Additionally, sometimes one is not overly concerned with many sections that cover only a short time duration. It is possible to exclude those by passing the optional argument threshold to the ``%print()`` method of ``timer_t``. Then, all child sections that took less than that threshold are subsumed under a single entry node (below threshold) and are not shown individually. That way the printed tree is still consistent in that all child nodes' values sum up to their parent's total, but unimportant nodes can be hidden.
***************
Error handling
***************
Optionally, you can have a custom error handling function for ftimings. This function can be as simple as:
.. code-block:: C
static void error_handler(ftimer_t *timer, void *handle, const char *string) {
fprintf(stderr, "Got error on timer '%s': %s\n", (char *) handle, string);
}
The error handling function must be registered with a timer name.
.. code-block:: C
const char *timername = "mytimer";
ftimings_register_error_handler(timer, error_handler, (void*) timername);
Overheads
=========
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment