]> git.ipfire.org Git - people/stevee/pakfire.git/blob - tools/rpmsw.h
Cleanup database and add indexes.
[people/stevee/pakfire.git] / tools / rpmsw.h
1 #ifndef H_RPMSW
2 #define H_RPMSW
3
4 /** \ingroup rpmio
5 * \file rpmio/rpmsw.h
6 */
7
8 /** \ingroup rpmio
9 */
10 typedef unsigned long int rpmtime_t;
11
12 /** \ingroup rpmio
13 */
14 typedef struct rpmsw_s * rpmsw;
15
16 /** \ingroup rpmio
17 */
18 typedef struct rpmop_s * rpmop;
19
20 /** \ingroup rpmio
21 */
22 struct rpmsw_s {
23 union {
24 struct timeval tv;
25 unsigned long long int ticks;
26 unsigned long int tocks[2];
27 } u;
28 };
29
30 /** \ingroup rpmio
31 * Cumulative statistics for an operation.
32 */
33 struct rpmop_s {
34 struct rpmsw_s begin; /*!< Starting time stamp. */
35 int count; /*!< Number of operations. */
36 unsigned long long bytes; /*!< Number of bytes transferred. */
37 rpmtime_t usecs; /*!< Number of ticks. */
38 };
39
40 /*@unchecked@*/
41 extern int _rpmsw_stats;
42
43 /** \ingroup rpmio
44 * Indices for timestamps.
45 */
46 typedef enum rpmswOpX_e {
47 RPMSW_OP_TOTAL = 0,
48 RPMSW_OP_CHECK = 1,
49 RPMSW_OP_ORDER = 2,
50 RPMSW_OP_FINGERPRINT = 3,
51 RPMSW_OP_REPACKAGE = 4,
52 RPMSW_OP_INSTALL = 5,
53 RPMSW_OP_ERASE = 6,
54 RPMSW_OP_SCRIPTLETS = 7,
55 RPMSW_OP_COMPRESS = 8,
56 RPMSW_OP_UNCOMPRESS = 9,
57 RPMSW_OP_DIGEST = 10,
58 RPMSW_OP_SIGNATURE = 11,
59 RPMSW_OP_DBADD = 12,
60 RPMSW_OP_DBREMOVE = 13,
61 RPMSW_OP_DBGET = 14,
62 RPMSW_OP_DBPUT = 15,
63 RPMSW_OP_DBDEL = 16,
64 RPMSW_OP_READHDR = 17,
65 RPMSW_OP_HDRLOAD = 18,
66 RPMSW_OP_HDRGET = 19,
67 RPMSW_OP_DEBUG = 20,
68 RPMSW_OP_MAX = 20
69 } rpmswOpX;
70
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74
75 /** Return benchmark time stamp.
76 * @param *sw time stamp
77 * @return 0 on success
78 */
79 /*@-exportlocal@*/
80 /*@null@*/
81 rpmsw rpmswNow(/*@returned@*/ rpmsw sw)
82 /*@globals internalState @*/
83 /*@modifies sw, internalState @*/;
84 /*@=exportlocal@*/
85
86 /** Return benchmark time stamp difference.
87 * @param *end end time stamp
88 * @param *begin begin time stamp
89 * @return difference in micro-seconds
90 */
91 /*@-exportlocal@*/
92 rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
93 /*@*/;
94 /*@=exportlocal@*/
95
96 /** Return benchmark time stamp overhead.
97 * @return overhead in micro-seconds
98 */
99 /*@-exportlocal@*/
100 rpmtime_t rpmswInit(void)
101 /*@globals internalState @*/
102 /*@modifies internalState @*/;
103 /*@=exportlocal@*/
104
105 /** \ingroup rpmio
106 * Enter timed operation.
107 * @param op operation statistics
108 * @param rc -1 clears usec counter
109 * @return 0 always
110 */
111 int rpmswEnter(/*@null@*/ rpmop op, ssize_t rc)
112 /*@globals internalState @*/
113 /*@modifies *op, internalState @*/;
114
115 /** \ingroup rpmio
116 * Exit timed operation.
117 * @param op operation statistics
118 * @param rc per-operation data (e.g. bytes transferred)
119 * @return cumulative usecs for operation
120 */
121 rpmtime_t rpmswExit(/*@null@*/ rpmop op, ssize_t rc)
122 /*@globals internalState @*/
123 /*@modifies op, internalState @*/;
124
125 /** \ingroup rpmio
126 * Sum statistic counters.
127 * @param to result statistics
128 * @param from operation statistics
129 * @return cumulative usecs for operation
130 */
131 rpmtime_t rpmswAdd(/*@null@*/ rpmop to, /*@null@*/ rpmop from)
132 /*@modifies to @*/;
133
134 /** \ingroup rpmio
135 * Subtract statistic counters.
136 * @param to result statistics
137 * @param from operation statistics
138 * @return cumulative usecs for operation
139 */
140 rpmtime_t rpmswSub(rpmop to, rpmop from)
141 /*@modifies to @*/;
142
143 /** \ingroup rpmio
144 * Print operation statistics.
145 * @param name operation name
146 * @param op operation statistics
147 * @param fp file handle (NULL uses stderr)
148 */
149 void rpmswPrint(const char * name, /*@null@*/ rpmop op, /*@null@*/ FILE * fp)
150 /*@globals fileSystem @*/
151 /*@modifies fp, fileSystem @*/;
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif /* H_RPMSW */