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"?>
|
||||
<!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>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -75,7 +75,7 @@
|
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">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="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.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
|
@ -137,10 +137,11 @@
|
|||
<valuemap type="QVariantMap" key="Qbs.Configuration">
|
||||
<value type="QString" key="qbs.defaultBuildVariant">release</value>
|
||||
<value type="QString" key="qbs.profile">qtc_Desktop_842209c4</value>
|
||||
<value type="bool" key="qbspm.forceProbes">false</value>
|
||||
</valuemap>
|
||||
<value type="bool" key="Qbs.DryKeepGoing">false</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.forceProbesKey">false</value>
|
||||
</valuemap>
|
||||
|
@ -246,19 +247,19 @@
|
|||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qbs.RunConfiguration:example-slowFastRendering.</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">example-slowFastRendering.</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</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.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</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>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
|
|
|
@ -14,8 +14,7 @@ namespace ofxProfiler {
|
|||
|
||||
using FloatingPointMicroseconds = chrono::duration <double, micro>;
|
||||
|
||||
struct ProfileResult
|
||||
{
|
||||
struct ProfileResult {
|
||||
string Name;
|
||||
|
||||
FloatingPointMicroseconds Start;
|
||||
|
@ -23,26 +22,26 @@ namespace ofxProfiler {
|
|||
thread::id ThreadID;
|
||||
};
|
||||
|
||||
struct InstrumentationSession
|
||||
{
|
||||
struct InstrumentationSession {
|
||||
string Name;
|
||||
};
|
||||
|
||||
class Instrumentor
|
||||
{
|
||||
class Instrumentor {
|
||||
private:
|
||||
mutex m_Mutex;
|
||||
InstrumentationSession * m_CurrentSession;
|
||||
ofstream m_OutputStream;
|
||||
public:
|
||||
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);
|
||||
if(!m_CurrentSession || !continueSession){
|
||||
// if there is no session, or it should not be continued
|
||||
if(m_CurrentSession){
|
||||
// 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
|
||||
|
@ -60,15 +59,14 @@ namespace ofxProfiler {
|
|||
ofLog(OF_LOG_ERROR, "Instrumentor could not open results file '%s'.", filepath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EndSession()
|
||||
{
|
||||
void EndSession(){
|
||||
lock_guard <mutex> lock(m_Mutex);
|
||||
InternalEndSession();
|
||||
}
|
||||
|
||||
void WriteProfile(const ProfileResult& result)
|
||||
{
|
||||
void WriteProfile(const ProfileResult & result){
|
||||
stringstream json;
|
||||
|
||||
string name = result.Name;
|
||||
|
@ -98,14 +96,12 @@ namespace ofxProfiler {
|
|||
}
|
||||
|
||||
private:
|
||||
void WriteHeader()
|
||||
{
|
||||
void WriteHeader(){
|
||||
m_OutputStream << "{\"otherData\": {},\"traceEvents\":[{}";
|
||||
m_OutputStream.flush();
|
||||
}
|
||||
|
||||
void WriteFooter()
|
||||
{
|
||||
void WriteFooter(){
|
||||
m_OutputStream << "]}";
|
||||
m_OutputStream.flush();
|
||||
}
|
||||
|
@ -123,23 +119,20 @@ namespace ofxProfiler {
|
|||
|
||||
};
|
||||
|
||||
class InstrumentationTimer
|
||||
{
|
||||
class InstrumentationTimer {
|
||||
public:
|
||||
InstrumentationTimer(const char * name)
|
||||
: m_Name(name), m_Stopped(false)
|
||||
{
|
||||
: m_Name(name), m_Stopped(false){
|
||||
m_StartTimepoint = chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
~InstrumentationTimer()
|
||||
{
|
||||
if (!m_Stopped)
|
||||
~InstrumentationTimer(){
|
||||
if(!m_Stopped){
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
void Stop(){
|
||||
auto endTimepoint = chrono::steady_clock::now();
|
||||
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();
|
||||
|
@ -156,7 +149,6 @@ namespace ofxProfiler {
|
|||
}
|
||||
|
||||
#define OFX_PROFILER 1
|
||||
#if OFX_PROFILER
|
||||
// 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
|
||||
// could mark the wrong one in your editor!
|
||||
|
@ -178,12 +170,15 @@ namespace ofxProfiler {
|
|||
#define OFX_PROFILER_FUNC_SIG "OFX_PROFILER_FUNC_SIG unknown!"
|
||||
#endif
|
||||
|
||||
#if OFX_PROFILER
|
||||
#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_SCOPE(name) ::ofxProfiler::InstrumentationTimer timer ## __LINE__(name);
|
||||
#define OFX_PROFILER_FUNCTION() OFX_PROFILER_SCOPE(OFX_PROFILER_FUNC_SIG)
|
||||
#else
|
||||
#define OFX_PROFILER_BEGIN_SESSION(name, filepath)
|
||||
#define OFX_PROFILER_CONTINUE_SESSION(name, filepath)
|
||||
#define OFX_PROFILER_END_SESSION()
|
||||
#define OFX_PROFILER_SCOPE(name)
|
||||
#define OFX_PROFILER_FUNCTION()
|
||||
|
|
Loading…
Reference in a new issue