mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
Event tracing fixes! Now working :)
This commit is contained in:
parent
05b56dcec0
commit
f5ed51e13a
@ -280,6 +280,7 @@ namespace profiler {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BaseBlockData(const BaseBlockData&) = default;
|
||||||
BaseBlockData(timestamp_t _begin_time, block_id_t _id);
|
BaseBlockData(timestamp_t _begin_time, block_id_t _id);
|
||||||
|
|
||||||
inline timestamp_t begin() const { return m_begin; }
|
inline timestamp_t begin() const { return m_begin; }
|
||||||
@ -288,6 +289,10 @@ namespace profiler {
|
|||||||
inline timestamp_t duration() const { return m_end - m_begin; }
|
inline timestamp_t duration() const { return m_end - m_begin; }
|
||||||
|
|
||||||
inline void setId(block_id_t _id) { m_id = _id; }
|
inline void setId(block_id_t _id) { m_id = _id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
BaseBlockData() = delete;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
if (!m_pRoot->sync.empty())
|
if (!m_pRoot->sync.empty())
|
||||||
{
|
{
|
||||||
_painter->setBrush(Qt::NoBrush);
|
_painter->setBrush(Qt::NoBrush);
|
||||||
QPen pen(QColor::fromRgba(0x40f08040));
|
QPen pen(QColor::fromRgba(0xe0f08040));
|
||||||
pen.setWidth(3);
|
pen.setWidth(3);
|
||||||
_painter->setPen(pen);
|
_painter->setPen(pen);
|
||||||
|
|
||||||
@ -528,10 +528,10 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
if (begin > sceneRight)
|
if (begin > sceneRight)
|
||||||
break; // This is first totally invisible item. No need to check other items.
|
break; // This is first totally invisible item. No need to check other items.
|
||||||
|
|
||||||
decltype(begin) width = item.node->duration();
|
decltype(begin) width = sceneView->time2position(item.node->end()) - begin;
|
||||||
auto r = begin + width;
|
auto r = begin + width;
|
||||||
// if (r < sceneLeft) // This item is not visible
|
if (r < sceneLeft) // This item is not visible
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
begin *= currentScale;
|
begin *= currentScale;
|
||||||
begin -= dx;
|
begin -= dx;
|
||||||
@ -1424,7 +1424,13 @@ void EasyGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocksTr
|
|||||||
for (const auto& threadTree : _blocksTree)
|
for (const auto& threadTree : _blocksTree)
|
||||||
{
|
{
|
||||||
const auto& tree = threadTree.second.children;
|
const auto& tree = threadTree.second.children;
|
||||||
const auto timestart = blocksTree(tree.front()).node->begin();
|
auto timestart = blocksTree(tree.front()).node->begin();
|
||||||
|
|
||||||
|
#ifdef EASY_STORE_CSWITCH_SEPARATELY
|
||||||
|
if (!threadTree.second.sync.empty())
|
||||||
|
timestart = ::std::min(timestart, blocksTree(threadTree.second.sync.front()).node->begin());
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto timefinish = blocksTree(tree.back()).node->end();
|
const auto timefinish = blocksTree(tree.back()).node->end();
|
||||||
|
|
||||||
if (m_beginTime > timestart)
|
if (m_beginTime > timestart)
|
||||||
|
@ -262,6 +262,11 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
cv.notify_all();
|
cv.notify_all();
|
||||||
|
|
||||||
|
for (int i = 0; i < RENDER_SPEPS; ++i) {
|
||||||
|
modellingStep();
|
||||||
|
localSleep(1200000);
|
||||||
|
}
|
||||||
|
|
||||||
render.join();
|
render.join();
|
||||||
modelling.join();
|
modelling.join();
|
||||||
for(auto& t : threads){
|
for(auto& t : threads){
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fstream>
|
|
||||||
#include "event_trace_win.h"
|
#include "event_trace_win.h"
|
||||||
#include "profiler/profiler.h"
|
#include "profiler/profiler.h"
|
||||||
#include "profile_manager.h"
|
#include "profile_manager.h"
|
||||||
@ -35,8 +34,6 @@ namespace profiler {
|
|||||||
|
|
||||||
void WINAPI processTraceEvent(PEVENT_RECORD _traceEvent)
|
void WINAPI processTraceEvent(PEVENT_RECORD _traceEvent)
|
||||||
{
|
{
|
||||||
//static ::std::ofstream outputFile("csw.csv", ::std::fstream::app);
|
|
||||||
|
|
||||||
static const decltype(_traceEvent->EventHeader.EventDescriptor.Opcode) SWITCH_CONTEXT_OPCODE = 36;
|
static const decltype(_traceEvent->EventHeader.EventDescriptor.Opcode) SWITCH_CONTEXT_OPCODE = 36;
|
||||||
if (_traceEvent->EventHeader.EventDescriptor.Opcode != SWITCH_CONTEXT_OPCODE)
|
if (_traceEvent->EventHeader.EventDescriptor.Opcode != SWITCH_CONTEXT_OPCODE)
|
||||||
return;
|
return;
|
||||||
@ -47,11 +44,6 @@ namespace profiler {
|
|||||||
auto _contextSwitchEvent = reinterpret_cast<CSwitch*>(_traceEvent->UserData);
|
auto _contextSwitchEvent = reinterpret_cast<CSwitch*>(_traceEvent->UserData);
|
||||||
|
|
||||||
auto timestampValue = _traceEvent->EventHeader.TimeStamp.QuadPart;
|
auto timestampValue = _traceEvent->EventHeader.TimeStamp.QuadPart;
|
||||||
|
|
||||||
//LARGE_INTEGER currtime;
|
|
||||||
//if (QueryPerformanceCounter(&currtime))
|
|
||||||
// timestampValue = currtime.QuadPart;
|
|
||||||
|
|
||||||
//timestampValue *= 1000000000LL;
|
//timestampValue *= 1000000000LL;
|
||||||
//timestampValue /= CPU_FREQUENCY;
|
//timestampValue /= CPU_FREQUENCY;
|
||||||
const auto time = (::profiler::timestamp_t)timestampValue;
|
const auto time = (::profiler::timestamp_t)timestampValue;
|
||||||
@ -59,14 +51,10 @@ namespace profiler {
|
|||||||
static const ::profiler::StaticBlockDescriptor desc("OS.ContextSwitch", __FILE__, __LINE__, ::profiler::BLOCK_TYPE_CONTEXT_SWITCH, ::profiler::colors::White);
|
static const ::profiler::StaticBlockDescriptor desc("OS.ContextSwitch", __FILE__, __LINE__, ::profiler::BLOCK_TYPE_CONTEXT_SWITCH, ::profiler::colors::White);
|
||||||
|
|
||||||
//if (_contextSwitchEvent->OldThreadId != 0)
|
//if (_contextSwitchEvent->OldThreadId != 0)
|
||||||
MANAGER._cswitchBeginBlock(time, desc.id(), _contextSwitchEvent->OldThreadId);
|
MANAGER._cswitchBeginBlock(time, desc.id(), _contextSwitchEvent->OldThreadId);
|
||||||
|
|
||||||
//if (_contextSwitchEvent->NewThreadId != 0)
|
//if (_contextSwitchEvent->NewThreadId != 0)
|
||||||
MANAGER._cswitchEndBlock(_contextSwitchEvent->NewThreadId, time);
|
MANAGER._cswitchEndBlock(_contextSwitchEvent->NewThreadId, time);
|
||||||
|
|
||||||
//static const auto firstTime = time;
|
|
||||||
//outputFile << _contextSwitchEvent->OldThreadId << "\t" << _contextSwitchEvent->NewThreadId << "\t" << (((time - firstTime) * 1000000000LL) / CPU_FREQUENCY) << ::std::endl;
|
|
||||||
//outputFile << _contextSwitchEvent->OldThreadId << "\t" << _contextSwitchEvent->NewThreadId << "\t" << time << ::std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -271,14 +271,10 @@ uint32_t ProfileManager::dumpBlocksToFile(const char* filename)
|
|||||||
of.write(descriptor.file(), filename_size);
|
of.write(descriptor.file(), filename_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
//::std::ofstream outputFile("csw2.csv", ::std::fstream::app);
|
|
||||||
|
|
||||||
for (auto& thread_storage : m_threads)
|
for (auto& thread_storage : m_threads)
|
||||||
{
|
{
|
||||||
auto& t = thread_storage.second;
|
auto& t = thread_storage.second;
|
||||||
|
|
||||||
//outputFile << thread_storage.first << std::endl;
|
|
||||||
|
|
||||||
of.write(thread_storage.first);
|
of.write(thread_storage.first);
|
||||||
#ifdef STORE_CSWITCHES_SEPARATELY
|
#ifdef STORE_CSWITCHES_SEPARATELY
|
||||||
of.write(static_cast<uint32_t>(t.blocks.closedList.size()));
|
of.write(static_cast<uint32_t>(t.blocks.closedList.size()));
|
||||||
@ -318,7 +314,6 @@ uint32_t ProfileManager::dumpBlocksToFile(const char* filename)
|
|||||||
{
|
{
|
||||||
auto b = t.sync.closedList[i];
|
auto b = t.sync.closedList[i];
|
||||||
#endif
|
#endif
|
||||||
//outputFile << b->begin() << "\t" << b->end() << std::endl;
|
|
||||||
|
|
||||||
of.writeBlock(b);
|
of.writeBlock(b);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_size = 0;
|
m_size = n;
|
||||||
m_chunks.emplace_back();
|
m_chunks.emplace_back();
|
||||||
return m_chunks.back().data;
|
return m_chunks.back().data;
|
||||||
}
|
}
|
||||||
@ -91,6 +91,8 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const uint16_t SIZEOF_CSWITCH = sizeof(profiler::BaseBlockData) + 1;
|
||||||
|
|
||||||
class ThreadStorage final
|
class ThreadStorage final
|
||||||
{
|
{
|
||||||
typedef std::vector<profiler::SerializedBlock*> serialized_list_t;
|
typedef std::vector<profiler::SerializedBlock*> serialized_list_t;
|
||||||
@ -114,8 +116,8 @@ class ThreadStorage final
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BlocksList<std::reference_wrapper<profiler::Block>, 1024> blocks;
|
BlocksList<std::reference_wrapper<profiler::Block>, SIZEOF_CSWITCH * (uint16_t)1024U> blocks;
|
||||||
BlocksList<profiler::Block, 1024> sync;
|
BlocksList<profiler::Block, SIZEOF_CSWITCH * (uint16_t)128U> sync;
|
||||||
bool named = false;
|
bool named = false;
|
||||||
|
|
||||||
void storeBlock(const profiler::Block& _block);
|
void storeBlock(const profiler::Block& _block);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user