2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-29 05:18:13 +00:00

9 Commits

Author SHA1 Message Date
Ben Pfaff
957ee508d2 stopwatch: Remove tabs from output.
OVS uses spaces for indentation in source code and it makes sense for it to
also use spaces for indentation in output.  Spaces also consume less
horizontal space in output, which often makes it easier to read.  This
commit transitions one part of output from tabs to spaces and updates
appropriate parts of the tests to match.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-06-11 15:31:55 -07:00
Mark Michelson
0f3d9fb485 stopwatch: Add latch_poll to stopwatch loop.
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>
2018-04-13 10:57:02 -07:00
Mark Michelson
484f7dbdaa stopwatch: Fix Windows incompatibility
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>
2018-04-10 13:29:15 -07:00
Justin Pettit
098ab9f145 stopwatch: Explicitly ignore write() return value.
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>
2018-04-06 12:55:55 -07:00
Justin Pettit
463ec4065b stopwatch: Fix some minor coding style issues.
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
2018-04-06 12:55:51 -07:00
Jakub Sitnicki
44c8281473 tests: Add tests for stopwatch module
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>
2018-04-03 14:02:43 -07:00
Jakub Sitnicki
0e124db81f stopwatch: Add API for waiting until samples have been processed
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>
2018-04-03 14:02:42 -07:00
Jakub Sitnicki
89189388d2 stopwatch: Add API for retrieving calculated statistics
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>
2018-04-03 14:02:41 -07:00
Mark Michelson
aed45befef Add stopwatch timing API
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>
2018-04-03 14:02:39 -07:00