blob: df18ee46502a01114ef2c3d96368c3a5f72b2f8b (
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
90
91
92
93
94
95
96
|
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#ifndef CARVE_USE_TIMINGS
#define CARVE_USE_TIMINGS 0
#endif
namespace carve {
#if CARVE_USE_TIMINGS
class TimingName {
public:
TimingName(const char *name);
int id;
};
class TimingBlock {
public:
/**
* Starts timing at the end of this constructor, using the given ID. To
* associate an ID with a textual name, use Timing::registerID.
*/
TimingBlock(int id);
TimingBlock(const TimingName &name);
~TimingBlock();
};
class Timing {
public:
/**
* Starts timing against a particular ID.
*/
static void start(int id);
static void start(const TimingName &id) {
start(id.id);
}
/**
* Stops the most recent timing block.
*/
static double stop();
/**
* This will print out the current state of recorded time blocks. It will
* display the tree of timings, as well as the summaries down the bottom.
*/
static void printTimings();
/**
* Associates a particular ID with a text string. This is used when
* printing out the timings.
*/
static void registerID(int id, const char *name);
};
#else
struct TimingName {
TimingName(const char *) {}
};
struct TimingBlock {
TimingBlock(int /* id */) {}
TimingBlock(const TimingName & /* name */) {}
};
struct Timing {
static void start(int /* id */) {}
static void start(const TimingName & /* id */) {}
static double stop() { return 0; }
static void printTimings() {}
static void registerID(int /* id */, const char * /* name */) {}
};
#endif
}
|