summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerstatsrecorder.h
blob: 001b8d9bd647445bde39013822f1d6bbfc565bb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
 * @file llviewerstatsrecorder.h
 * @brief record info about viewer events to a metrics log file
 *
 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#ifndef LLVIEWERSTATSRECORDER_H
#define LLVIEWERSTATSRECORDER_H


// This is a diagnostic class used to record information from the viewer
// for analysis.

// This is normally 0.  Set to 1 to enable viewer stats recording
#define LL_RECORD_VIEWER_STATS	1


#if LL_RECORD_VIEWER_STATS
#include "llframetimer.h"
#include "llviewerobject.h"

class LLMutex;
class LLViewerRegion;
class LLViewerObject;

class LLViewerStatsRecorder
{
 public:
	LLViewerStatsRecorder();
	~LLViewerStatsRecorder();

	static void initClass();
	static void cleanupClass();
	static LLViewerStatsRecorder* instance() {return sInstance; }

	void initStatsRecorder(LLViewerRegion *regionp);

	void beginObjectUpdateEvents(LLViewerRegion *regionp);
	void recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type);
	void recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type);
	void recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp);
	void recordRequestCacheMissesEvent(S32 count);
	void endObjectUpdateEvents();

private:
	static LLViewerStatsRecorder* sInstance;

	LLFILE *	mObjectCacheFile;		// File to write data into
	LLFrameTimer	mTimer;
	LLViewerRegion*	mRegionp;
	F64			mStartTime;
	F64			mProcessingTime;

	S32			mObjectCacheHitCount;
	S32			mObjectCacheMissFullCount;
	S32			mObjectCacheMissCrcCount;
	S32			mObjectFullUpdates;
	S32			mObjectTerseUpdates;
	S32			mObjectCacheMissRequests;
	S32			mObjectCacheMissResponses;
	S32			mObjectUpdateFailures;


	void	clearStats();
};
#endif	// LL_RECORD_VIEWER_STATS

#endif // LLVIEWERSTATSRECORDER_H