Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
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
41extern void stats_vfs_file_add(size_t file_size);
42extern void stats_vfs_file_remove(size_t file_size);
43extern void stats_vfs_init_start();
44extern void stats_vfs_init_finish();
45
46// file
47
48// currently not called because string_pool is now in lib/allocators
49extern void stats_unique_name(size_t name_len);
50extern void stats_open();
51extern void stats_close();
52
53// file_buf
54extern void stats_buf_alloc(size_t size, size_t alignedSize);
55extern void stats_buf_free();
56extern void stats_buf_ref();
57
58// file_io
59extern 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.
67{
68public:
71 void NotifyOfSuccess(FileIOImplentation fi, int opcode, off_t size);
72
73private:
74 double m_startTime;
75};
76
77extern void stats_cb_start();
78extern void stats_cb_finish();
79
80// file_cache
81extern void stats_block_cache(CacheRet cr);
82
83// archive builder
84extern void stats_ab_connection(bool already_exists);
85
86extern void file_stats_dump();
87
88#else
89
90#define stats_vfs_file_add(file_size)
91#define stats_vfs_file_remove(file_size)
92#define stats_vfs_init_start()
93#define stats_vfs_init_finish()
94#define stats_unique_name(name_len)
95#define stats_open()
96#define stats_close()
97#define stats_buf_alloc(size, alignedSize)
98#define stats_buf_free()
99#define stats_buf_ref()
100#define stats_io_user_request(user_size)
102{
103public:
107};
108#define stats_cb_start()
109#define stats_cb_finish()
110#define stats_block_cache(cr)
111#define stats_ab_connection(already_exists)
112#define file_stats_dump()
113
114#endif
115
116#endif // #ifndef INCLUDED_FILE_STATS
Definition: file_stats.h:102
~ScopedIoMonitor()
Definition: file_stats.h:105
ScopedIoMonitor()
Definition: file_stats.h:104
void NotifyOfSuccess(FileIOImplentation fi, int opcode, off_t size)
Definition: file_stats.h:106
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning.
Definition: code_annotation.h:40
#define stats_open()
Definition: file_stats.h:95
CacheRet
Definition: file_stats.h:36
@ CR_HIT
Definition: file_stats.h:36
@ CR_MISS
Definition: file_stats.h:36
#define stats_io_user_request(user_size)
Definition: file_stats.h:100
#define stats_vfs_file_remove(file_size)
Definition: file_stats.h:91
#define stats_buf_alloc(size, alignedSize)
Definition: file_stats.h:97
#define stats_buf_ref()
Definition: file_stats.h:99
#define stats_unique_name(name_len)
Definition: file_stats.h:94
#define stats_ab_connection(already_exists)
Definition: file_stats.h:111
FileIOImplentation
Definition: file_stats.h:35
@ FI_BCACHE
Definition: file_stats.h:35
@ FI_AIO
Definition: file_stats.h:35
@ FI_MAX_IDX
Definition: file_stats.h:35
@ FI_LOWIO
Definition: file_stats.h:35
#define stats_vfs_file_add(file_size)
Definition: file_stats.h:90
#define file_stats_dump()
Definition: file_stats.h:112
#define stats_cb_finish()
Definition: file_stats.h:109
#define stats_block_cache(cr)
Definition: file_stats.h:110
#define stats_close()
Definition: file_stats.h:96
#define stats_vfs_init_start()
Definition: file_stats.h:92
#define stats_buf_free()
Definition: file_stats.h:98
#define stats_vfs_init_finish()
Definition: file_stats.h:93
#define stats_cb_start()
Definition: file_stats.h:108
__int64 off_t
Definition: wposix_types.h:91