11 #include "../platform.h" 20 typedef std::chrono::time_point< std::chrono::high_resolution_clock > time_point;
21 typedef std::chrono::high_resolution_clock clock;
22 typedef std::chrono::microseconds time;
33 timer(std::chrono::microseconds &_elapsedTime)
44 elapsedTime += std::chrono::duration_cast<std::chrono::microseconds>(clock::now() -
start);
65 template <
typename TReturnType,
typename TClassType,
typename TMemFunc,
typename... TArgs >
66 TReturnType instrument(time &_profileTime, TClassType *_classType, TMemFunc _func, TArgs... _params)
68 timer profile_timer(_profileTime);
69 return (_classType->*_func)(std::forward< TArgs >(_params)...);
89 virtual void suppress(
enum type _error) = 0;
90 virtual void unsuppress(
enum type _error) = 0;
92 template<
class TInterface,
class TKey = TInterface>
93 friend TInterface*
get();
100 template <
class TErrorImplementation>
108 void suppress(
enum type _error)
override 110 error_implementation.suppress(_error);
111 stack.push_front(_error);
114 void unsuppress(
enum type _error)
override 116 enum type stack_item;
117 stack.pop_front(stack_item);
118 ts_assert(stack_item == _error);
119 error_implementation.unsuppress(_error);
124 memory_allocator_type dispenser;
125 TErrorImplementation error_implementation;
131 ts_declare_attribute_and_callbacks(
memory,
const tchar_t*, name);
134 : ts_init_attribute_and_callbacks(
memory, name, _t(
""))
139 get<errors>()->suppress(errors::type::memory);
144 get<errors>()->unsuppress(errors::memory);
147 virtual void allocate_begin(
size_t _size,
bool _initialized) {
148 ts_unused(_size); ts_unused(_initialized);
151 virtual void allocate_end(
void** _memory_allocation,
size_t _size,
bool _initialized) {
152 ts_unused(_memory_allocation); ts_unused(_size); ts_unused(_initialized);
155 template <
class TKey>
156 static memory* instance();
160 void memory::set_name(
const tchar_t* _name)
165 const tchar_t* memory::get_name()
167 return (&name)->c_str();
173 inline void suppress()
175 get<errors>()->suppress(errors::threads);
178 inline void unsuppress()
180 get<errors>()->unsuppress(errors::threads);
185 inline void suppress()
187 get<errors>()->suppress(errors::all);
190 inline void unsuppress()
192 get<errors>()->unsuppress(errors::all);
195 template <
class TStringImplementation>
201 : TStringImplementation(_name)
205 typename TStringImplementation::handle& operator* ()
207 return TStringImplementation::operator*();
215 typedef void* handle;
217 ts_declare_attribute_and_callbacks(
domain,
const tchar_t*, name);
220 : ts_init_attribute_and_callbacks(
domain, name, _t(
""))
224 virtual handle operator* () {
return hdl; }
226 template <
class TKey>
227 static domain* instance();
232 void domain::set_name(
const tchar_t* _name)
237 const tchar_t* domain::get_name()
239 return (&name)->c_str();
244 typedef void* handle;
246 template <
class TFuncType>
247 function(TFuncType _func)
248 : function_ptr((
void*)_func)
252 typename handle& operator* ()
Definition: profilebase.h:242
Struct timer
Definition: profilebase.h:27
Class stl_allocator.
Definition: allocator.h:16
Definition: profilebase.h:212
time & elapsedTime
The elapsed time
Definition: profilebase.h:54
Definition: profilebase.h:101
Definition: profilebase.h:128
Class profile_mem_interface.
Definition: profilebase.h:75
Definition: profilebase.h:196
~timer()
Finalizes an instance of the timer class.
Definition: profilebase.h:42
Definition: profilebase.h:80
time_point start
The start
Definition: profilebase.h:50
timer(std::chrono::microseconds &_elapsedTime)
Initializes a new instance of the timer struct.
Definition: profilebase.h:33