2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* An abstracted interface for recording fs statistics data */
12 #include <afsconfig.h>
13 #include <afs/param.h>
17 #include <afs/afsint.h>
18 #include <afs/ihandle.h>
26 fsstats_StartOp(struct fsstats *stats, int index)
29 stats->opP = &(afs_FullPerfStats.det.rpcOpTimes[index]);
31 (stats->opP->numOps)++;
33 FT_GetTimeOfDay(&stats->opStartTime, NULL);
37 fsstats_FinishOp(struct fsstats *stats, int code)
39 struct timeval opStopTime, elapsedTime;
41 FT_GetTimeOfDay(&opStopTime, NULL);
44 (stats->opP->numSuccesses)++;
45 fs_stats_GetDiff(elapsedTime, stats->opStartTime, opStopTime);
46 fs_stats_AddTo((stats->opP->sumTime), elapsedTime);
47 fs_stats_SquareAddTo((stats->opP->sqrTime), elapsedTime);
48 if (fs_stats_TimeLessThan(elapsedTime, (stats->opP->minTime))) {
49 fs_stats_TimeAssign((stats->opP->minTime), elapsedTime);
51 if (fs_stats_TimeGreaterThan(elapsedTime, (stats->opP->maxTime))) {
52 fs_stats_TimeAssign((stats->opP->maxTime), elapsedTime);
59 fsstats_StartXfer(struct fsstats *stats)
61 FT_GetTimeOfDay(&stats->xferStartTime, NULL);
62 stats->xferP = &(afs_FullPerfStats.det.xferOpTimes[stats->index]);
66 fsstats_FinishXfer(struct fsstats *stats, int code,
67 afs_sfsize_t bytesToXfer, afs_sfsize_t bytesXferred,
70 struct timeval xferStopTime;
71 struct timeval elapsedTime;
74 * At this point, the data transfer is done, for good or ill. Remember
75 * when the transfer ended, bump the number of successes/failures, and
76 * integrate the transfer size and elapsed time into the stats. If the
77 * operation failed, we jump to the appropriate point.
79 FT_GetTimeOfDay(&xferStopTime, 0);
81 (stats->xferP->numXfers)++;
83 (stats->xferP->numSuccesses)++;
86 * Bump the xfer sum by the number of bytes actually sent, NOT the
89 *remainder += bytesXferred;
90 (stats->xferP->sumBytes) += (*remainder >> 10);
92 if (bytesXferred < stats->xferP->minBytes)
93 stats->xferP->minBytes = bytesXferred;
94 if (bytesXferred > stats->xferP->maxBytes)
95 stats->xferP->maxBytes = bytesXferred;
98 * Tally the size of the object. Note: we tally the actual size,
99 * NOT the number of bytes that made it out over the wire.
101 if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET0)
102 (stats->xferP->count[0])++;
103 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET1)
104 (stats->xferP->count[1])++;
105 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET2)
106 (stats->xferP->count[2])++;
107 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET3)
108 (stats->xferP->count[3])++;
109 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET4)
110 (stats->xferP->count[4])++;
111 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET5)
112 (stats->xferP->count[5])++;
113 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET6)
114 (stats->xferP->count[6])++;
115 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET7)
116 (stats->xferP->count[7])++;
118 (stats->xferP->count[8])++;
120 fs_stats_GetDiff(elapsedTime, stats->xferStartTime, xferStopTime);
121 fs_stats_AddTo((stats->xferP->sumTime), elapsedTime);
122 fs_stats_SquareAddTo((stats->xferP->sqrTime), elapsedTime);
123 if (fs_stats_TimeLessThan(elapsedTime, (stats->xferP->minTime))) {
124 fs_stats_TimeAssign((stats->xferP->minTime), elapsedTime);
126 if (fs_stats_TimeGreaterThan(elapsedTime, (stats->xferP->maxTime))) {
127 fs_stats_TimeAssign((stats->xferP->maxTime), elapsedTime);
136 fsstats_StartOp(struct fsstats *stats, int index)
142 fsstats_FinishOp(struct fsstats *stats, int code)
148 fsstats_StartXfer(struct fsstats *stats)
154 fsstats_FinishXfer(struct fsstats *stats, int code,
155 afs_sfsize_t bytesToXfer, afs_sfsize_t bytesXferred,