mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
#67 [Converter] Build fix after merging to release_2_0
This commit is contained in:
parent
2232407685
commit
e3f1dfad10
@ -57,20 +57,20 @@ inline bool isCompatibleVersion(uint32_t _version)
|
|||||||
|
|
||||||
#ifdef EASY_PROFILER_HASHED_CSTR_DEFINED
|
#ifdef EASY_PROFILER_HASHED_CSTR_DEFINED
|
||||||
|
|
||||||
typedef ::std::unordered_map<::profiler::block_id_t, ::profiler::BlockStatistics*, ::profiler::passthrough_hash<::profiler::block_id_t> > StatsMap;
|
using StatsMap = ::std::unordered_map<::profiler::block_id_t, ::profiler::BlockStatistics*, ::estd::hash<::profiler::block_id_t> >;
|
||||||
|
|
||||||
/** \note It is absolutely safe to use hashed_cstr (which simply stores pointer) because std::unordered_map,
|
/** \note It is absolutely safe to use hashed_cstr (which simply stores pointer) because std::unordered_map,
|
||||||
which uses it as a key, exists only inside fillTreesFromFile function. */
|
which uses it as a key, exists only inside fillTreesFromFile function. */
|
||||||
typedef ::std::unordered_map<::profiler::hashed_cstr, ::profiler::block_id_t> IdMap;
|
using IdMap = ::std::unordered_map<::profiler::hashed_cstr, ::profiler::block_id_t>;
|
||||||
|
|
||||||
typedef ::std::unordered_map<::profiler::hashed_cstr, ::profiler::BlockStatistics*> CsStatsMap;
|
using CsStatsMap = ::std::unordered_map<::profiler::hashed_cstr, ::profiler::BlockStatistics*>;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// TODO: Create optimized version of profiler::hashed_cstr for Linux too.
|
// TODO: Create optimized version of profiler::hashed_cstr for Linux too.
|
||||||
typedef ::std::unordered_map<::profiler::block_id_t, ::profiler::BlockStatistics*, ::profiler::passthrough_hash<::profiler::block_id_t> > StatsMap;
|
using StatsMap = ::std::unordered_map<::profiler::block_id_t, ::profiler::BlockStatistics*, ::estd::hash<::profiler::block_id_t> >;
|
||||||
typedef ::std::unordered_map<::profiler::hashed_stdstring, ::profiler::block_id_t> IdMap;
|
using IdMap = ::std::unordered_map<::profiler::hashed_stdstring, ::profiler::block_id_t>;
|
||||||
typedef ::std::unordered_map<::profiler::hashed_stdstring, ::profiler::BlockStatistics*> CsStatsMap;
|
using CsStatsMap = ::std::unordered_map<::profiler::hashed_stdstring, ::profiler::BlockStatistics*>;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -125,8 +125,8 @@ using namespace profiler::reader;
|
|||||||
|
|
||||||
int64_t file_cpu_frequency = 0LL;
|
int64_t file_cpu_frequency = 0LL;
|
||||||
inFile.read((char*)&file_cpu_frequency, sizeof(int64_t));
|
inFile.read((char*)&file_cpu_frequency, sizeof(int64_t));
|
||||||
uint64_t cpu_frequency = file_cpu_frequency;
|
const uint64_t cpu_frequency = file_cpu_frequency;
|
||||||
const double conversion_factor = static_cast<double>(TIME_FACTOR) / static_cast<double>(cpu_frequency);
|
const double conversion_factor = (cpu_frequency != 0 ? static_cast<double>(TIME_FACTOR) / static_cast<double>(cpu_frequency) : 1.);
|
||||||
|
|
||||||
::profiler::timestamp_t begin_time = 0ULL;
|
::profiler::timestamp_t begin_time = 0ULL;
|
||||||
::profiler::timestamp_t end_time = 0ULL;
|
::profiler::timestamp_t end_time = 0ULL;
|
||||||
@ -189,14 +189,15 @@ using namespace profiler::reader;
|
|||||||
inFile.read(data, sz);
|
inFile.read(data, sz);
|
||||||
auto descriptor = reinterpret_cast<::profiler::SerializedBlockDescriptor*>(data);
|
auto descriptor = reinterpret_cast<::profiler::SerializedBlockDescriptor*>(data);
|
||||||
|
|
||||||
m_BlockDescriptors.push_back(::std::make_shared<BlockDescriptor>());
|
auto desc = ::std::make_shared<BlockDescriptor>();
|
||||||
m_BlockDescriptors.back()->lineNumber = descriptor->line();
|
desc->lineNumber = descriptor->line();
|
||||||
m_BlockDescriptors.back()->blockId = descriptor->id();
|
desc->blockId = descriptor->id();
|
||||||
m_BlockDescriptors.back()->argbColor = descriptor->color();
|
desc->argbColor = descriptor->color();
|
||||||
m_BlockDescriptors.back()->blockType = descriptor->type();
|
desc->blockType = static_cast<decltype(desc->blockType)>(descriptor->type());
|
||||||
m_BlockDescriptors.back()->status = descriptor->status();
|
desc->status = descriptor->status();
|
||||||
m_BlockDescriptors.back()->compileTimeName = descriptor->name();
|
desc->compileTimeName = descriptor->name();
|
||||||
m_BlockDescriptors.back()->fileName = descriptor->file();
|
desc->fileName = descriptor->file();
|
||||||
|
m_BlockDescriptors.push_back(::std::move(desc));
|
||||||
|
|
||||||
i += sz;
|
i += sz;
|
||||||
}
|
}
|
||||||
@ -281,7 +282,7 @@ using namespace profiler::reader;
|
|||||||
prev_node->current_block = ::std::make_shared<BlockInfo>();
|
prev_node->current_block = ::std::make_shared<BlockInfo>();
|
||||||
|
|
||||||
::std::shared_ptr<BlocksTreeNode> element;
|
::std::shared_ptr<BlocksTreeNode> element;
|
||||||
uint level = 0;
|
uint32_t level = 0;
|
||||||
|
|
||||||
while (!inFile.eof() && read_number < threshold)
|
while (!inFile.eof() && read_number < threshold)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,45 @@
|
|||||||
|
/**
|
||||||
|
Lightweight profiler library for c++
|
||||||
|
Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin
|
||||||
|
|
||||||
|
Licensed under either of
|
||||||
|
* MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT)
|
||||||
|
* Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
at your option.
|
||||||
|
|
||||||
|
The MIT License
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
The Apache License, Version 2.0 (the "License");
|
||||||
|
You may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
#ifndef EASY_PROFILER_READER_H
|
#ifndef EASY_PROFILER_READER_H
|
||||||
#define EASY_PROFILER_READER_H
|
#define EASY_PROFILER_READER_H
|
||||||
|
|
||||||
@ -12,49 +54,39 @@
|
|||||||
///this
|
///this
|
||||||
#include <easy/easy_protocol.h>
|
#include <easy/easy_protocol.h>
|
||||||
#include <easy/reader.h>
|
#include <easy/reader.h>
|
||||||
|
#include <easy/utility.h>
|
||||||
|
|
||||||
#ifndef uint
|
namespace profiler {
|
||||||
#define uint unsigned int
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace profiler{
|
|
||||||
|
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
|
||||||
|
class BlocksTreeNode;
|
||||||
|
using thread_blocks_tree_t = ::std::unordered_map<::profiler::thread_id_t, BlocksTreeNode, ::estd::hash<::profiler::thread_id_t> >;
|
||||||
|
using thread_names_t = ::std::unordered_map<::profiler::thread_id_t, ::std::string>;
|
||||||
|
using context_switches_t = ::std::vector<::std::shared_ptr<ContextSwitchEvent> >;
|
||||||
|
|
||||||
class BlocksTreeNode
|
class BlocksTreeNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
::std::vector<::std::shared_ptr<BlocksTreeNode>> children;
|
||||||
::std::shared_ptr<BlockInfo> current_block;
|
::std::shared_ptr<BlockInfo> current_block;
|
||||||
BlocksTreeNode* parent;
|
BlocksTreeNode* parent;
|
||||||
::std::vector<::std::shared_ptr<BlocksTreeNode>> children;
|
|
||||||
|
|
||||||
BlocksTreeNode(BlocksTreeNode&& other)
|
BlocksTreeNode(BlocksTreeNode&& other) : children(::std::move(other.children))
|
||||||
: current_block(::std::move(other.current_block)),
|
, current_block(::std::move(other.current_block))
|
||||||
parent(other.parent),
|
, parent(other.parent)
|
||||||
children(::std::move(other.children))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
BlocksTreeNode():current_block(nullptr),
|
|
||||||
parent(nullptr)
|
BlocksTreeNode() : parent(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
}; // end of class BlocksTreeNode.
|
||||||
|
|
||||||
typedef ::std::unordered_map<::profiler::thread_id_t, BlocksTreeNode, ::profiler::passthrough_hash<::profiler::thread_id_t> > thread_blocks_tree_t;
|
|
||||||
typedef ::std::unordered_map<::profiler::thread_id_t, ::std::string> thread_names_t;
|
|
||||||
typedef ::std::vector<::std::shared_ptr<ContextSwitchEvent> > context_switches_t;
|
|
||||||
|
|
||||||
class FileReader EASY_FINAL
|
class FileReader EASY_FINAL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
FileReader()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
~FileReader()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------*/
|
/*-----------------------------------------------------------------*/
|
||||||
///initial read file with RAW data
|
///initial read file with RAW data
|
||||||
::profiler::block_index_t readFile(const ::std::string& filename);
|
::profiler::block_index_t readFile(const ::std::string& filename);
|
||||||
@ -78,6 +110,7 @@ public:
|
|||||||
/*-----------------------------------------------------------------*/
|
/*-----------------------------------------------------------------*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
///serialized raw data
|
///serialized raw data
|
||||||
::profiler::SerializedData serialized_blocks, serialized_descriptors;
|
::profiler::SerializedData serialized_blocks, serialized_descriptors;
|
||||||
///error log stream
|
///error log stream
|
||||||
@ -91,8 +124,11 @@ private:
|
|||||||
std::vector<std::shared_ptr<BlockDescriptor>> m_BlockDescriptors;
|
std::vector<std::shared_ptr<BlockDescriptor>> m_BlockDescriptors;
|
||||||
///data file version
|
///data file version
|
||||||
uint32_t m_version;
|
uint32_t m_version;
|
||||||
};
|
|
||||||
|
|
||||||
} //namespace reader
|
}; // end of class FileReader.
|
||||||
} //namespace profiler
|
|
||||||
#endif //EASY_PROFILER_READER_H
|
} // end of namespace reader.
|
||||||
|
|
||||||
|
} // end of namespace profiler.
|
||||||
|
|
||||||
|
#endif // EASY_PROFILER_READER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user