doxygen groupings for rpmsw, add to librpm + hacking dox
[platform/upstream/rpm.git] / rpmio / rpmsw.h
1 #ifndef H_RPMSW
2 #define H_RPMSW
3
4 /** \ingroup rpmio
5  * \file rpmio/rpmsw.h
6  */
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /** \ingroup rpmsw
13  */
14 typedef unsigned long int rpmtime_t;
15
16 /** \ingroup rpmsw
17  */
18 typedef struct rpmsw_s * rpmsw;
19
20 /** \ingroup rpmsw
21  */
22 typedef struct rpmop_s * rpmop;
23
24 /** \ingroup rpmsw
25  */
26 struct rpmsw_s {
27     union {
28         struct timeval tv;
29         unsigned long long int ticks;
30         unsigned long int tocks[2];
31     } u;
32 };
33
34 /** \ingroup rpmsw
35  * Cumulative statistics for an operation.
36  */
37 struct rpmop_s {
38     struct rpmsw_s      begin;  /*!< Starting time stamp. */
39     int                 count;  /*!< Number of operations. */
40     size_t              bytes;  /*!< Number of bytes transferred. */
41     rpmtime_t           usecs;  /*!< Number of ticks. */
42 };
43
44 /** \ingroup rpmsw
45  * Return benchmark time stamp.
46  * @param *sw           time stamp
47  * @return              0 on success
48  */
49 rpmsw rpmswNow(rpmsw sw);
50
51 /** \ingroup rpmsw
52  * Return benchmark time stamp difference.
53  * @param *end          end time stamp
54  * @param *begin        begin time stamp
55  * @return              difference in micro-seconds
56  */
57 rpmtime_t rpmswDiff(rpmsw end, rpmsw begin);
58
59 /** \ingroup rpmsw
60  * Return benchmark time stamp overhead.
61  * @return              overhead in micro-seconds
62  */
63 rpmtime_t rpmswInit(void);
64
65 /** \ingroup rpmsw
66  * Enter timed operation.
67  * @param op                    operation statistics
68  * @param rc                    -1 clears usec counter
69  * @return                      0 always
70  */
71 int rpmswEnter(rpmop op, ssize_t rc);
72
73 /** \ingroup rpmsw
74  * Exit timed operation.
75  * @param op                    operation statistics
76  * @param rc                    per-operation data (e.g. bytes transferred)
77  * @return                      cumulative usecs for operation
78  */
79 rpmtime_t rpmswExit(rpmop op, ssize_t rc);
80
81 /** \ingroup rpmsw
82  * Sum statistic counters.
83  * @param to                    result statistics
84  * @param from                  operation statistics
85  * @return                      cumulative usecs for operation
86  */
87 rpmtime_t rpmswAdd(rpmop to, rpmop from);
88
89 /** \ingroup rpmsw
90  * Subtract statistic counters.
91  * @param to                    result statistics
92  * @param from                  operation statistics
93  * @return                      cumulative usecs for operation
94  */
95 rpmtime_t rpmswSub(rpmop to, rpmop from);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif  /* H_RPMSW */