-
Notifications
You must be signed in to change notification settings - Fork 2
/
ScoreProfiler.h
111 lines (84 loc) · 3.05 KB
/
ScoreProfiler.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 1999 The Regents of the University of California
// Permission to use, copy, modify, and distribute this software and
// its documentation for any purpose, without fee, and without a
// written agreement is hereby granted, provided that the above copyright
// notice and this paragraph and the following two paragraphs appear in
// all copies.
//
// IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
// LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
// EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
// AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
// PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
//////////////////////////////////////////////////////////////////////////////
//
// BRASS source file
//
// $Id: ScoreProfiler.h,v 2.3 2001/10/26 04:01:49 yurym Exp $
//
// supports all profiling
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _ScoreProfiler_h__
#define _ScoreProfiler_h__
#include <stdio.h>
#include <values.h>
#include <stdlib.h>
#include <iostream>
#include <assert.h>
using std::ostream;
typedef unsigned long long statDataType;
class CategoryRecord {
public:
CategoryRecord() { reset(); }
void print(ostream &s, statDataType overall_total = 0ull,
bool summarize = false, bool totalOnly = false);
void addSample(statDataType v);
void reset();
bool empty() const { return (_count == 0); }
/* accessors */
statDataType total() const { return _total; }
statDataType min() const { return _min; }
statDataType max() const { return _max; }
unsigned int count() const { return _count; }
statDataType lastVal() const { return _lastVal; }
private:
statDataType _total;
statDataType _min;
statDataType _max;
unsigned int _count;
statDataType _lastVal;
};
class ScoreProfiler {
public:
ScoreProfiler(size_t num_cats, const char *str[], bool add_perItem = false,
const char *greeting_str = 0);
~ScoreProfiler();
void addSample(unsigned int ts,
size_t index, statDataType v, bool verbose = false);
void addSample_perItem(size_t index, statDataType v, unsigned int count,
bool verbose);
void print(ostream &s, bool summarize = true, bool totalOnly = false);
void finishTS(bool verbose = false);
statDataType aggregate() const { return _aggregate; }
statDataType lastVal(size_t index);
private:
size_t _count;
const char **_str;
CategoryRecord *_recs;
CategoryRecord *_recs_perItem;
CategoryRecord _summary_rec;
statDataType _aggregate;
unsigned int _curr_ts;
const char *_greeting_str;
};
#endif