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>
18 #include <afs/afsint.h>
19 #include <afs/ihandle.h>
26 fsstats_StartOp(struct fsstats *stats, int index)
28 assert(index >= 0 && index < FS_STATS_NUM_RPC_OPS);
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, int index)
61 assert(index >= 0 && index < FS_STATS_NUM_XFER_OPS);
62 FT_GetTimeOfDay(&stats->xferStartTime, NULL);
63 stats->xferP = &(afs_FullPerfStats.det.xferOpTimes[index]);
67 fsstats_FinishXfer(struct fsstats *stats, int code,
68 afs_sfsize_t bytesToXfer, afs_sfsize_t bytesXferred,
71 struct timeval xferStopTime;
72 struct timeval elapsedTime;
75 * At this point, the data transfer is done, for good or ill. Remember
76 * when the transfer ended, bump the number of successes/failures, and
77 * integrate the transfer size and elapsed time into the stats. If the
78 * operation failed, we jump to the appropriate point.
80 FT_GetTimeOfDay(&xferStopTime, 0);
82 (stats->xferP->numXfers)++;
84 (stats->xferP->numSuccesses)++;
87 * Bump the xfer sum by the number of bytes actually sent, NOT the
90 *remainder += bytesXferred;
91 (stats->xferP->sumBytes) += (*remainder >> 10);
93 if (bytesXferred < stats->xferP->minBytes)
94 stats->xferP->minBytes = bytesXferred;
95 if (bytesXferred > stats->xferP->maxBytes)
96 stats->xferP->maxBytes = bytesXferred;
99 * Tally the size of the object. Note: we tally the actual size,
100 * NOT the number of bytes that made it out over the wire.
102 if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET0)
103 (stats->xferP->count[0])++;
104 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET1)
105 (stats->xferP->count[1])++;
106 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET2)
107 (stats->xferP->count[2])++;
108 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET3)
109 (stats->xferP->count[3])++;
110 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET4)
111 (stats->xferP->count[4])++;
112 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET5)
113 (stats->xferP->count[5])++;
114 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET6)
115 (stats->xferP->count[6])++;
116 else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET7)
117 (stats->xferP->count[7])++;
119 (stats->xferP->count[8])++;
121 fs_stats_GetDiff(elapsedTime, stats->xferStartTime, xferStopTime);
122 fs_stats_AddTo((stats->xferP->sumTime), elapsedTime);
123 fs_stats_SquareAddTo((stats->xferP->sqrTime), elapsedTime);
124 if (fs_stats_TimeLessThan(elapsedTime, (stats->xferP->minTime))) {
125 fs_stats_TimeAssign((stats->xferP->minTime), elapsedTime);
127 if (fs_stats_TimeGreaterThan(elapsedTime, (stats->xferP->maxTime))) {
128 fs_stats_TimeAssign((stats->xferP->maxTime), elapsedTime);