summaryrefslogtreecommitdiff
path: root/lib/stopwatch.c
Commit message (Collapse)AuthorAgeFilesLines
* stopwatch: Add latch_poll to stopwatch loop.Mark Michelson2018-04-131-0/+1
| | | | | | | | Nothing was clearing the latch, so the loop was busy. This makes it so the loop only runs on new calls to latch_set() by a separate thread. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* stopwatch: Fix Windows incompatibilityMark Michelson2018-04-101-38/+54
| | | | | | | | | Stopwatch was implemented using a Unix-only pipe structure. This commit changes to using a guarded list and latch in order to pass data between threads. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* stopwatch: Explicitly ignore write() return value.Justin Pettit2018-04-061-5/+6
| | | | | | | | | | | | | | In some environments, builds would fail with the following error: lib/stopwatch.c: In function ‘stopwatch_exit’: lib/stopwatch.c:448:5: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result] write(stopwatch_pipe[1], &pkt, sizeof pkt); This patch explicitly ignores the return value of write(). Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* stopwatch: Fix some minor coding style issues.Justin Pettit2018-04-061-11/+11
| | | | | Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* tests: Add tests for stopwatch moduleJakub Sitnicki2018-04-031-1/+1
| | | | | | | | Check if stopwatch module is calculating statistics as expected. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* stopwatch: Add API for waiting until samples have been processedJakub Sitnicki2018-04-031-8/+26
| | | | | | | | Will be used for testing the module. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* stopwatch: Add API for retrieving calculated statisticsJakub Sitnicki2018-04-031-0/+34
| | | | | | | | Will be used for testing the module. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Add stopwatch timing APIMark Michelson2018-04-031-0/+483
This is similar to the existing coverage and perf-counter APIs in OVS. However, rather than keeping counters, this is aimed at timing how long operations take to perform. "Operations" in this case can be anything from a loop iteration, to a function, to something more complex. The library allows for named stopwatches to be created. From there, the stopwatch can be started and stopped via stopwatch_start() and stopwatch_stop(). After each run, statistics for the stopwatch will be calculated. Statistics for a particular stopwatch can be queried from the command line by using ovs-appctl -t <target> stopwatch/show <stopwatch name>. Statistics can be reset from the command line using ovs-appctl -t <target> stopwatch/reset <stopwatch name> Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>