Pyrogenesis  trunk
file_stats.h
Go to the documentation of this file.
1 /* Copyright (c) 2010 Wildfire Games
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 /*
24  * gathers statistics from all file modules.
25  */
26 
27 #ifndef INCLUDED_FILE_STATS
28 #define INCLUDED_FILE_STATS
29 
30 #include "lib/posix/posix_aio.h" // LIO_READ, LIO_WRITE
31 
32 #define FILE_STATS_ENABLED 0
33 
34 
37 
38 #if FILE_STATS_ENABLED
39 
40 // vfs
41 extern void stats_vfs_file_add(size_t file_size);
42 extern void stats_vfs_file_remove(size_t file_size);
43 extern void stats_vfs_init_start();
44 extern void stats_vfs_init_finish();
45 
46 // file
47 
48 // currently not called because string_pool is now in lib/allocators
49 extern void stats_unique_name(size_t name_len);
50 extern void stats_open();
51 extern void stats_close();
52 
53 // file_buf
54 extern void stats_buf_alloc(size_t size, size_t alignedSize);
55 extern void stats_buf_free();
56 extern void stats_buf_ref();
57 
58 // file_io
59 extern void stats_io_user_request(size_t user_size);
60 
61 // this is used to measure effective throughput for the two
62 // synchronous IO variants.
63 // note: improved measurements of the actual aio throughput by instrumenting
64 // issue/wait doesn't work because IOManager's decompression may cause us to
65 // miss the exact end of IO, thus throwing off measurements.
66 class ScopedIoMonitor
67 {
68 public:
71  void NotifyOfSuccess(FileIOImplentation fi, int opcode, off_t size);
72 
73 private:
74  double m_startTime;
75 };
76 
77 extern void stats_cb_start();
78 extern void stats_cb_finish();
79 
80 // file_cache
81 extern void stats_cache(CacheRet cr, size_t size);
82 extern void stats_block_cache(CacheRet cr);
83 
84 // archive builder
85 extern void stats_ab_connection(bool already_exists);
86 
87 extern void file_stats_dump();
88 
89 #else
90 
91 #define stats_vfs_file_add(file_size)
92 #define stats_vfs_file_remove(file_size)
93 #define stats_vfs_init_start()
94 #define stats_vfs_init_finish()
95 #define stats_unique_name(name_len)
96 #define stats_open()
97 #define stats_close()
98 #define stats_buf_alloc(size, alignedSize)
99 #define stats_buf_free()
100 #define stats_buf_ref()
101 #define stats_io_user_request(user_size)
103 {
104 public:
107  void NotifyOfSuccess(FileIOImplentation UNUSED(fi), int UNUSED(opcode), off_t UNUSED(size)) {}
108 };
109 #define stats_cb_start()
110 #define stats_cb_finish()
111 #define stats_cache(cr, size)
112 #define stats_block_cache(cr)
113 #define stats_ab_connection(already_exists)
114 #define file_stats_dump()
115 
116 #endif
117 
118 #endif // #ifndef INCLUDED_FILE_STATS
#define stats_unique_name(name_len)
Definition: file_stats.h:95
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
Definition: code_annotation.h:38
#define stats_open()
Definition: file_stats.h:96
Definition: file_stats.h:102
Definition: file_stats.h:35
Definition: file_stats.h:35
Definition: file_stats.h:35
ScopedIoMonitor()
Definition: file_stats.h:105
#define stats_cb_start()
Definition: file_stats.h:109
__int64 off_t
Definition: wposix_types.h:91
#define file_stats_dump()
Definition: file_stats.h:114
Definition: file_stats.h:35
Definition: file_stats.h:36
void NotifyOfSuccess(FileIOImplentation fi, int opcode, off_t size)
Definition: file_stats.h:107
#define stats_cb_finish()
Definition: file_stats.h:110
#define stats_io_user_request(user_size)
Definition: file_stats.h:101
#define stats_vfs_file_remove(file_size)
Definition: file_stats.h:92
FileIOImplentation
Definition: file_stats.h:35
#define stats_close()
Definition: file_stats.h:97
#define stats_buf_ref()
Definition: file_stats.h:100
#define stats_buf_free()
Definition: file_stats.h:99
#define stats_block_cache(cr)
Definition: file_stats.h:112
~ScopedIoMonitor()
Definition: file_stats.h:106
Definition: file_stats.h:36
#define stats_cache(cr, size)
Definition: file_stats.h:111
#define stats_buf_alloc(size, alignedSize)
Definition: file_stats.h:98
#define stats_vfs_file_add(file_size)
Definition: file_stats.h:91
#define stats_vfs_init_finish()
Definition: file_stats.h:94
#define stats_vfs_init_start()
Definition: file_stats.h:93
#define stats_ab_connection(already_exists)
Definition: file_stats.h:113
CacheRet
Definition: file_stats.h:36