mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 16:11:02 +08:00
Replace tab to whitespaces
This commit is contained in:
parent
d39fecaac1
commit
cd39507389
@ -2,8 +2,8 @@ project(profiling_tool)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(
|
||||
ROOT
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
ROOT
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set(OUTPUT_DIR
|
||||
@ -23,16 +23,16 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
|
||||
)
|
||||
|
||||
include_directories(
|
||||
include
|
||||
include
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-reorder -pedantic -O3" )
|
||||
else()
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
endif(UNIX)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
@ -84,19 +84,19 @@ namespace profiler {
|
||||
/** Macro of beginning of block with custom name and color.
|
||||
|
||||
\code
|
||||
#include "profiler/profiler.h"
|
||||
void foo()
|
||||
{
|
||||
// some code ...
|
||||
if(something){
|
||||
EASY_BLOCK("Calling bar()"); // Block with default color
|
||||
bar();
|
||||
}
|
||||
#include "profiler/profiler.h"
|
||||
void foo()
|
||||
{
|
||||
// some code ...
|
||||
if(something){
|
||||
EASY_BLOCK("Calling bar()"); // Block with default color
|
||||
bar();
|
||||
}
|
||||
else{
|
||||
EASY_BLOCK("Calling baz()", profiler::colors::Red); // Red block
|
||||
baz();
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
Block will be automatically completed by destructor.
|
||||
@ -112,11 +112,11 @@ Block will be automatically completed by destructor.
|
||||
/** Macro of beginning of block with function name and custom color.
|
||||
|
||||
\code
|
||||
#include "profiler/profiler.h"
|
||||
void foo(){
|
||||
EASY_FUNCTION(); // Block with name="foo" and default color
|
||||
//some code...
|
||||
}
|
||||
#include "profiler/profiler.h"
|
||||
void foo(){
|
||||
EASY_FUNCTION(); // Block with name="foo" and default color
|
||||
//some code...
|
||||
}
|
||||
|
||||
void bar(){
|
||||
EASY_FUNCTION(profiler::colors::Green); // Green block with name="bar"
|
||||
@ -142,12 +142,12 @@ int foo()
|
||||
{
|
||||
// some code ...
|
||||
|
||||
int sum = 0;
|
||||
EASY_BLOCK("Calculating sum");
|
||||
for (int i = 0; i < 10; ++i){
|
||||
sum += i;
|
||||
}
|
||||
EASY_END_BLOCK;
|
||||
int sum = 0;
|
||||
EASY_BLOCK("Calculating sum");
|
||||
for (int i = 0; i < 10; ++i){
|
||||
sum += i;
|
||||
}
|
||||
EASY_END_BLOCK;
|
||||
|
||||
// some antoher code here ...
|
||||
|
||||
@ -219,10 +219,10 @@ This is only for user comfort. There is no difference for EasyProfiler GUI betwe
|
||||
#include "profiler/profiler_colors.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _BUILD_PROFILER
|
||||
#define PROFILER_API __declspec(dllexport)
|
||||
#ifdef _BUILD_PROFILER
|
||||
#define PROFILER_API __declspec(dllexport)
|
||||
#else
|
||||
#define PROFILER_API __declspec(dllimport)
|
||||
#define PROFILER_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PROFILER_API
|
||||
@ -233,7 +233,7 @@ class ThreadStorage;
|
||||
|
||||
namespace profiler {
|
||||
|
||||
class Block;
|
||||
class Block;
|
||||
|
||||
typedef uint64_t timestamp_t;
|
||||
typedef uint32_t thread_id_t;
|
||||
@ -249,8 +249,8 @@ namespace profiler {
|
||||
BLOCK_TYPES_NUMBER
|
||||
};
|
||||
typedef BlockType block_type_t;
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern "C" {
|
||||
PROFILER_API block_id_t registerDescription(const char* _name, const char* _filename, int _line, block_type_t _block_type, color_t _color = DefaultBlockColor);
|
||||
PROFILER_API void beginBlock(Block& _block);
|
||||
PROFILER_API void endBlock();
|
||||
@ -259,8 +259,8 @@ namespace profiler {
|
||||
PROFILER_API const char* setThreadName(const char* name, const char* filename, const char* _funcname, int line);
|
||||
PROFILER_API void setContextSwitchLogFilename(const char* name);
|
||||
PROFILER_API const char* getContextSwitchLogFilename();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma pack(push,1)
|
||||
class PROFILER_API BaseBlockDescriptor
|
||||
{
|
||||
|
@ -38,17 +38,17 @@ decltype(LARGE_INTEGER::QuadPart) CPU_FREQUENCY = ([](){ LARGE_INTEGER freq; Que
|
||||
inline timestamp_t getCurrentTime()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
//see https://msdn.microsoft.com/library/windows/desktop/dn553408(v=vs.85).aspx
|
||||
LARGE_INTEGER elapsedMicroseconds;
|
||||
if (!QueryPerformanceCounter(&elapsedMicroseconds))
|
||||
return 0;
|
||||
//see https://msdn.microsoft.com/library/windows/desktop/dn553408(v=vs.85).aspx
|
||||
LARGE_INTEGER elapsedMicroseconds;
|
||||
if (!QueryPerformanceCounter(&elapsedMicroseconds))
|
||||
return 0;
|
||||
//elapsedMicroseconds.QuadPart *= 1000000000LL;
|
||||
//elapsedMicroseconds.QuadPart /= CPU_FREQUENCY;
|
||||
return (timestamp_t)elapsedMicroseconds.QuadPart;
|
||||
return (timestamp_t)elapsedMicroseconds.QuadPart;
|
||||
#else
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> time_point;
|
||||
time_point = std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now());
|
||||
return time_point.time_since_epoch().count();
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> time_point;
|
||||
time_point = std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now());
|
||||
return time_point.time_since_epoch().count();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -68,19 +68,19 @@ extern "C" {
|
||||
}
|
||||
|
||||
PROFILER_API void beginBlock(Block& _block)
|
||||
{
|
||||
{
|
||||
MANAGER.beginBlock(_block);
|
||||
}
|
||||
}
|
||||
|
||||
PROFILER_API uint32_t dumpBlocksToFile(const char* filename)
|
||||
{
|
||||
PROFILER_API uint32_t dumpBlocksToFile(const char* filename)
|
||||
{
|
||||
return MANAGER.dumpBlocksToFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
PROFILER_API const char* setThreadName(const char* name, const char* filename, const char* _funcname, int line)
|
||||
{
|
||||
{
|
||||
return MANAGER.setThreadName(name, filename, _funcname, line);
|
||||
}
|
||||
}
|
||||
|
||||
PROFILER_API void setContextSwitchLogFilename(const char* name)
|
||||
{
|
||||
@ -175,7 +175,7 @@ ProfileManager::ProfileManager()
|
||||
|
||||
ProfileManager::~ProfileManager()
|
||||
{
|
||||
//dumpBlocksToFile("test.prof");
|
||||
//dumpBlocksToFile("test.prof");
|
||||
}
|
||||
|
||||
ProfileManager& ProfileManager::instance()
|
||||
@ -249,7 +249,7 @@ void ProfileManager::endContextSwitch(profiler::thread_id_t _thread_id, profiler
|
||||
|
||||
void ProfileManager::setEnabled(bool isEnable)
|
||||
{
|
||||
m_isEnabled = isEnable;
|
||||
m_isEnabled = isEnable;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -182,7 +182,7 @@ class ProfileManager final
|
||||
public:
|
||||
|
||||
static ProfileManager& instance();
|
||||
~ProfileManager();
|
||||
~ProfileManager();
|
||||
|
||||
template <class ... TArgs>
|
||||
uint32_t addBlockDescriptor(TArgs ... _args)
|
||||
@ -194,8 +194,8 @@ public:
|
||||
}
|
||||
|
||||
void beginBlock(profiler::Block& _block);
|
||||
void endBlock();
|
||||
void setEnabled(bool isEnable);
|
||||
void endBlock();
|
||||
void setEnabled(bool isEnable);
|
||||
uint32_t dumpBlocksToFile(const char* filename);
|
||||
const char* setThreadName(const char* name, const char* filename, const char* _funcname, int line);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user