Coda Distributed File System
timecalls.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 6
5
6 Copyright (c) 1987-2003 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19#ifndef _TIMECALLS_H_
20#define _TIMECALLS_H_
21
22#ifdef __cplusplus
23extern "C" {
24#endif __cplusplus
25
26#include <stdio.h>
27#include <sys/time.h>
28#include <sys/file.h>
29#include "coda_assert.h"
30#include <mach.h>
31
32#include <sys/ioctl.h>
33#ifdef __cplusplus
34}
35#endif __cplusplus
36
37extern int clockFD;
38extern struct hgram Create_Total_hg, Remove_Total_hg, Link_Total_hg;
39extern struct hgram Rename_Total_hg, MakeDir_Total_hg, RemoveDir_Total_hg,
40 SymLink_Total_hg, SpoolVMLogRecord_hg, PutObjects_Transaction_hg,
41 PutObjects_TransactionEnd_hg, PutObjects_Inodes_hg, PutObjects_RVM_hg;
42
43#ifdef __STDC__
44#define NSC_SHOW_COUNTER_INFO _IO('c', 0)
45#define NSC_GET_COUNTER _IOR('c', 1, long)
46#else __STDC__
47#define NSC_SHOW_COUNTER_INFO _IO(c, 0)
48#define NSC_GET_COUNTER _IOR(c, 1, long)
49#endif __STDC__
50
51#ifdef _TIMECALLS_
52#define START_NSC_TIMING(id) \
53 START_TIMING(id) \
54 unsigned long a id, b id; \
55 float timediff id; \
56 struct timeval after id, before id; \
57 { \
58 if (clockFD > 0) \
59 ioctl(clockFD, NSC_GET_COUNTER, &b id); \
60 else \
61 gettimeofday(&before id, 0); \
62 }
63
64#define END_NSC_TIMING(id) \
65 { \
66 END_TIMING(id) \
67 if (clockFD > 0) { \
68 ioctl(clockFD, NSC_GET_COUNTER, &a id); \
69 if (a id > b id) \
70 timediff id = (a id - b id) / 25; \
71 else { \
72 float tmp1 = (b id - a id) / 25; \
73 timediff id = (171798691.84 - tmp1); \
74 } \
75 } else { \
76 gettimeofday(&after id, 0); \
77 timediff id = \
78 (after id.tv_sec - before id.tv_sec) * 1000000 + \
79 after id.tv_usec - before id.tv_usec; \
80 } \
81 UpdateHisto(&id _hg, (double)timediff id); \
82 }
83#else /* !_TIMECALLS_ */
84#define START_NSC_TIMING(id) START_TIMING(id)
85#define END_NSC_TIMING(id) END_TIMING(id)
86#endif
87
88#endif /* _TIMECALLS_H_ */
Definition: histo.h:45
__cplusplus __cplusplus int clockFD
struct hgram Rename_Total_hg MakeDir_Total_hg RemoveDir_Total_hg SymLink_Total_hg SpoolVMLogRecord_hg PutObjects_Transaction_hg PutObjects_TransactionEnd_hg PutObjects_Inodes_hg PutObjects_RVM_hg
struct hgram Create_Total_hg Remove_Total_hg Link_Total_hg