add continue session and uncrustify
This commit is contained in:
parent
0fa9dd430b
commit
0b8fb261fa
2 changed files with 95 additions and 99 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.12.0, 2020-05-17T10:10:28. -->
|
<!-- Written by QtCreator 4.12.0, 2020-09-29T16:34:27. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{a59f5d47-09f7-45f4-8f6a-af2e6553b46c}</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{a59f5d47-09f7-45f4-8f6a-af2e6553b46c}</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
@ -137,10 +137,11 @@
|
||||||
<valuemap type="QVariantMap" key="Qbs.Configuration">
|
<valuemap type="QVariantMap" key="Qbs.Configuration">
|
||||||
<value type="QString" key="qbs.defaultBuildVariant">release</value>
|
<value type="QString" key="qbs.defaultBuildVariant">release</value>
|
||||||
<value type="QString" key="qbs.profile">qtc_Desktop_842209c4</value>
|
<value type="QString" key="qbs.profile">qtc_Desktop_842209c4</value>
|
||||||
|
<value type="bool" key="qbspm.forceProbes">false</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="bool" key="Qbs.DryKeepGoing">false</value>
|
<value type="bool" key="Qbs.DryKeepGoing">false</value>
|
||||||
<value type="bool" key="Qbs.Install">true</value>
|
<value type="bool" key="Qbs.Install">true</value>
|
||||||
<value type="int" key="Qbs.MaxJobs">0</value>
|
<value type="int" key="Qbs.MaxJobs">48</value>
|
||||||
<value type="bool" key="Qbs.ShowCommandLines">false</value>
|
<value type="bool" key="Qbs.ShowCommandLines">false</value>
|
||||||
<value type="bool" key="Qbs.forceProbesKey">false</value>
|
<value type="bool" key="Qbs.forceProbesKey">false</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
|
@ -246,19 +247,19 @@
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qbs.RunConfiguration:example-slowFastRendering.</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">example-slowFastRendering.</value>
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
|
||||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/pointer/of_v0.11.0_linux64gcc6_release/addons/ofxProfiler/example-slowFastRendering/bin</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
|
|
|
@ -14,8 +14,7 @@ namespace ofxProfiler {
|
||||||
|
|
||||||
using FloatingPointMicroseconds = chrono::duration <double, micro>;
|
using FloatingPointMicroseconds = chrono::duration <double, micro>;
|
||||||
|
|
||||||
struct ProfileResult
|
struct ProfileResult {
|
||||||
{
|
|
||||||
string Name;
|
string Name;
|
||||||
|
|
||||||
FloatingPointMicroseconds Start;
|
FloatingPointMicroseconds Start;
|
||||||
|
@ -23,26 +22,26 @@ namespace ofxProfiler {
|
||||||
thread::id ThreadID;
|
thread::id ThreadID;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InstrumentationSession
|
struct InstrumentationSession {
|
||||||
{
|
|
||||||
string Name;
|
string Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Instrumentor
|
class Instrumentor {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
mutex m_Mutex;
|
mutex m_Mutex;
|
||||||
InstrumentationSession * m_CurrentSession;
|
InstrumentationSession * m_CurrentSession;
|
||||||
ofstream m_OutputStream;
|
ofstream m_OutputStream;
|
||||||
public:
|
public:
|
||||||
Instrumentor()
|
Instrumentor()
|
||||||
: m_CurrentSession(nullptr)
|
: m_CurrentSession(nullptr){
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginSession(const string& name, const string& filepath = "results.json")
|
void BeginSession(const string & name = "I do not want to name my profiling sessions.",
|
||||||
{
|
const string & filepath = "results.json",
|
||||||
|
const bool continueSession = false){
|
||||||
lock_guard <mutex> lock(m_Mutex);
|
lock_guard <mutex> lock(m_Mutex);
|
||||||
|
if(!m_CurrentSession || !continueSession){
|
||||||
|
// if there is no session, or it should not be continued
|
||||||
if(m_CurrentSession){
|
if(m_CurrentSession){
|
||||||
// If there is already a current session, then close it before beginning new one.
|
// If there is already a current session, then close it before beginning new one.
|
||||||
// Subsequent profiling output meant for the original session will end up in the
|
// Subsequent profiling output meant for the original session will end up in the
|
||||||
|
@ -60,15 +59,14 @@ namespace ofxProfiler {
|
||||||
ofLog(OF_LOG_ERROR, "Instrumentor could not open results file '%s'.", filepath.c_str());
|
ofLog(OF_LOG_ERROR, "Instrumentor could not open results file '%s'.", filepath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EndSession()
|
void EndSession(){
|
||||||
{
|
|
||||||
lock_guard <mutex> lock(m_Mutex);
|
lock_guard <mutex> lock(m_Mutex);
|
||||||
InternalEndSession();
|
InternalEndSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteProfile(const ProfileResult& result)
|
void WriteProfile(const ProfileResult & result){
|
||||||
{
|
|
||||||
stringstream json;
|
stringstream json;
|
||||||
|
|
||||||
string name = result.Name;
|
string name = result.Name;
|
||||||
|
@ -98,14 +96,12 @@ namespace ofxProfiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void WriteHeader()
|
void WriteHeader(){
|
||||||
{
|
|
||||||
m_OutputStream << "{\"otherData\": {},\"traceEvents\":[{}";
|
m_OutputStream << "{\"otherData\": {},\"traceEvents\":[{}";
|
||||||
m_OutputStream.flush();
|
m_OutputStream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteFooter()
|
void WriteFooter(){
|
||||||
{
|
|
||||||
m_OutputStream << "]}";
|
m_OutputStream << "]}";
|
||||||
m_OutputStream.flush();
|
m_OutputStream.flush();
|
||||||
}
|
}
|
||||||
|
@ -123,23 +119,20 @@ namespace ofxProfiler {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InstrumentationTimer
|
class InstrumentationTimer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
InstrumentationTimer(const char * name)
|
InstrumentationTimer(const char * name)
|
||||||
: m_Name(name), m_Stopped(false)
|
: m_Name(name), m_Stopped(false){
|
||||||
{
|
|
||||||
m_StartTimepoint = chrono::steady_clock::now();
|
m_StartTimepoint = chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
~InstrumentationTimer()
|
~InstrumentationTimer(){
|
||||||
{
|
if(!m_Stopped){
|
||||||
if (!m_Stopped)
|
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Stop()
|
void Stop(){
|
||||||
{
|
|
||||||
auto endTimepoint = chrono::steady_clock::now();
|
auto endTimepoint = chrono::steady_clock::now();
|
||||||
auto highResStart = FloatingPointMicroseconds{m_StartTimepoint.time_since_epoch()};
|
auto highResStart = FloatingPointMicroseconds{m_StartTimepoint.time_since_epoch()};
|
||||||
auto elapsedTime = chrono::time_point_cast <chrono::microseconds>(endTimepoint).time_since_epoch() - chrono::time_point_cast <chrono::microseconds>(m_StartTimepoint).time_since_epoch();
|
auto elapsedTime = chrono::time_point_cast <chrono::microseconds>(endTimepoint).time_since_epoch() - chrono::time_point_cast <chrono::microseconds>(m_StartTimepoint).time_since_epoch();
|
||||||
|
@ -156,7 +149,6 @@ namespace ofxProfiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OFX_PROFILER 1
|
#define OFX_PROFILER 1
|
||||||
#if OFX_PROFILER
|
|
||||||
// Resolve which function signature macro will HZ_PROFILE_BEGIN_SESSIONbe used. Note that this only
|
// Resolve which function signature macro will HZ_PROFILE_BEGIN_SESSIONbe used. Note that this only
|
||||||
// is resolved when the (pre)compiler starts, so the syntax highlighting
|
// is resolved when the (pre)compiler starts, so the syntax highlighting
|
||||||
// could mark the wrong one in your editor!
|
// could mark the wrong one in your editor!
|
||||||
|
@ -178,12 +170,15 @@ namespace ofxProfiler {
|
||||||
#define OFX_PROFILER_FUNC_SIG "OFX_PROFILER_FUNC_SIG unknown!"
|
#define OFX_PROFILER_FUNC_SIG "OFX_PROFILER_FUNC_SIG unknown!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OFX_PROFILER
|
||||||
#define OFX_PROFILER_BEGIN_SESSION(name, filepath) ::ofxProfiler::Instrumentor::Get().BeginSession(name, filepath)
|
#define OFX_PROFILER_BEGIN_SESSION(name, filepath) ::ofxProfiler::Instrumentor::Get().BeginSession(name, filepath)
|
||||||
|
#define OFX_PROFILER_CONTINUE_SESSION(name, filepath) ::ofxProfiler::Instrumentor::Get().BeginSession(name, filepath, true)
|
||||||
#define OFX_PROFILER_END_SESSION() ::ofxProfiler::Instrumentor::Get().EndSession()
|
#define OFX_PROFILER_END_SESSION() ::ofxProfiler::Instrumentor::Get().EndSession()
|
||||||
#define OFX_PROFILER_SCOPE(name) ::ofxProfiler::InstrumentationTimer timer ## __LINE__(name);
|
#define OFX_PROFILER_SCOPE(name) ::ofxProfiler::InstrumentationTimer timer ## __LINE__(name);
|
||||||
#define OFX_PROFILER_FUNCTION() OFX_PROFILER_SCOPE(OFX_PROFILER_FUNC_SIG)
|
#define OFX_PROFILER_FUNCTION() OFX_PROFILER_SCOPE(OFX_PROFILER_FUNC_SIG)
|
||||||
#else
|
#else
|
||||||
#define OFX_PROFILER_BEGIN_SESSION(name, filepath)
|
#define OFX_PROFILER_BEGIN_SESSION(name, filepath)
|
||||||
|
#define OFX_PROFILER_CONTINUE_SESSION(name, filepath)
|
||||||
#define OFX_PROFILER_END_SESSION()
|
#define OFX_PROFILER_END_SESSION()
|
||||||
#define OFX_PROFILER_SCOPE(name)
|
#define OFX_PROFILER_SCOPE(name)
|
||||||
#define OFX_PROFILER_FUNCTION()
|
#define OFX_PROFILER_FUNCTION()
|
||||||
|
|
Loading…
Reference in a new issue