Daniele Bartolini 10 лет назад
Родитель
Сommit
bc2dd80fb4
2 измененных файлов с 26 добавлено и 5 удалено
  1. 5 5
      src/core/profiler.cpp
  2. 21 0
      src/core/profiler.h

+ 5 - 5
src/core/profiler.cpp

@@ -37,11 +37,11 @@ namespace profiler_globals
 namespace profiler
 {
 	enum { THREAD_BUFFER_SIZE = 4 * 1024 };
-	char _thread_buffer[THREAD_BUFFER_SIZE];
-	uint32_t _thread_buffer_size = 0;
-	Mutex _buffer_mutex;
+	static char _thread_buffer[THREAD_BUFFER_SIZE];
+	static uint32_t _thread_buffer_size = 0;
+	static Mutex _buffer_mutex;
 
-	void flush_local_buffer()
+	static void flush_local_buffer()
 	{
 		ScopedMutex sm(_buffer_mutex);
 		array::push(*profiler_globals::_buffer, _thread_buffer, _thread_buffer_size);
@@ -49,7 +49,7 @@ namespace profiler
 	}
 
 	template <typename T>
-	void push(ProfilerEventType::Enum type, const T& ev)
+	static void push(ProfilerEventType::Enum type, const T& ev)
 	{
 		if (_thread_buffer_size + 2*sizeof(uint32_t) + sizeof(ev) >= THREAD_BUFFER_SIZE)
 			flush_local_buffer();

+ 21 - 0
src/core/profiler.h

@@ -11,6 +11,8 @@
 namespace crown
 {
 
+/// @defgroup Profiler Profiler
+
 struct ProfilerEventType
 {
 	enum Enum
@@ -61,13 +63,32 @@ struct DeallocateMemory
 	uint32_t size;
 };
 
+/// Functions to access profiler.
+///
+/// @ingroup Profiler
+///
+/// @note
+/// The profiler does not copy pointer data.
+/// You have to store it somewhere and make sure it is
+/// valid throughout the program execution.
 namespace profiler
 {
+	/// Starts a new profile scope with the given @a name.
 	void enter_profile_scope(const char* name);
+
+	/// Ends the last profile scope.
 	void leave_profile_scope();
+
+	/// Records the float @a value with the given @a name.
 	void record_float(const char* name, float value);
+
+	/// Records the vector3 @a value with the given @a name.
 	void record_vector3(const char* name, const Vector3& value);
+
+	/// Records a memory allocation of @a size with the given @a name.
 	void allocate_memory(const char* name, uint32_t size);
+
+	/// Records a memory deallocation of @a size with the given @a name.
 	void deallocate_memory(const char* name, uint32_t size);
 } // namespace profiler