0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

linux build

This commit is contained in:
Sergey Yagovtsev 2016-06-19 22:28:17 +03:00
parent a9018888f1
commit c09d928393
2 changed files with 27 additions and 33 deletions

View File

@ -14,7 +14,7 @@ add_definitions(
add_executable(${PROJECT_NAME} ${SOURCES}) add_executable(${PROJECT_NAME} ${SOURCES})
if(UNIX) if(UNIX)
set(SPEC_LIB pthread) set(SPEC_LIB pthread shared_allocator)
endif(UNIX) endif(UNIX)
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB}) target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})

View File

@ -13,22 +13,24 @@
struct BlocksTree struct BlocksTree
{ {
profiler::SerilizedBlock* node; profiler::SerilizedBlock* node;
std::vector<BlocksTree> children; std::vector<BlocksTree > children;
BlocksTree* parent; BlocksTree* parent;
BlocksTree(){ BlocksTree(){
node = nullptr; node = nullptr;
parent = nullptr; parent = nullptr;
} }
BlocksTree(BlocksTree&& that){
node = that.node; BlocksTree(BlocksTree&& that)
parent = that.parent; {
makeMove(std::forward<BlocksTree&&>(that));
children = std::move(that.children);
that.node = nullptr;
that.parent = nullptr;
} }
BlocksTree& operator=(BlocksTree&& that)
{
makeMove(std::forward<BlocksTree&&>(that));
return *this;
}
~BlocksTree(){ ~BlocksTree(){
if (node){ if (node){
delete node; delete node;
@ -37,27 +39,6 @@ struct BlocksTree
parent = nullptr; parent = nullptr;
} }
BlocksTree(const BlocksTree& rhs)
{
copy(rhs);
}
BlocksTree& copy(const BlocksTree& rhs)
{
if(this == &rhs)
return *this;
if(rhs.node)
node = new profiler::SerilizedBlock(*rhs.node);
children = rhs.children;
parent = rhs.parent;
return *this;
}
BlocksTree& operator=(const BlocksTree& rhs)
{
return copy(rhs);
}
bool operator < (const BlocksTree& other) const bool operator < (const BlocksTree& other) const
{ {
if (!node || !other.node){ if (!node || !other.node){
@ -65,6 +46,19 @@ struct BlocksTree
} }
return node->block()->getBegin() < other.node->block()->getBegin(); return node->block()->getBegin() < other.node->block()->getBegin();
} }
private:
void makeMove(BlocksTree&& that)
{
node = that.node;
parent = that.parent;
children = std::move(that.children);
that.node = nullptr;
that.parent = nullptr;
}
}; };
int main() int main()
@ -80,6 +74,7 @@ int main()
thread_blocks_tree_t threaded_trees; thread_blocks_tree_t threaded_trees;
int blocks_counter = 0; int blocks_counter = 0;
auto start = std::chrono::system_clock::now(); auto start = std::chrono::system_clock::now();
while (!inFile.eof()){ while (!inFile.eof()){
uint16_t sz = 0; uint16_t sz = 0;
@ -106,7 +101,7 @@ int main()
BlocksTree& back = root.children.back(); BlocksTree& back = root.children.back();
auto t1 = back.node->block()->getEnd(); auto t1 = back.node->block()->getEnd();
auto mt0 = tree.node->block()->getBegin(); auto mt0 = tree.node->block()->getBegin();
if (mt0 < t1)//parent - starts ealier than last ends if (mt0 < t1)//parent - starts earlier than last ends
{ {
auto lower = std::lower_bound(root.children.begin(), root.children.end(), tree); auto lower = std::lower_bound(root.children.begin(), root.children.end(), tree);
@ -114,7 +109,6 @@ int main()
root.children.erase(lower, root.children.end()); root.children.erase(lower, root.children.end());
} }
root.children.push_back(std::move(tree)); root.children.push_back(std::move(tree));