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

Replace tab to whitespaces

This commit is contained in:
Sergey Yagovtsev 2016-09-06 22:23:55 +03:00
parent ede383be3c
commit 68ee40a5ad
11 changed files with 202 additions and 202 deletions

View File

@ -134,7 +134,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
EasyTreeWidget::~EasyTreeWidget() EasyTreeWidget::~EasyTreeWidget()
{ {
saveSettings(); saveSettings();
delete m_progress; delete m_progress;
} }
@ -298,10 +298,10 @@ void EasyTreeWidget::clearSilent(bool _global)
for (int i = topLevelItemCount() - 1; i >= 0; --i) for (int i = topLevelItemCount() - 1; i >= 0; --i)
topLevelItems.push_back(takeTopLevelItem(i)); topLevelItems.push_back(takeTopLevelItem(i));
auto deleter_thread = ::std::thread([](decltype(topLevelItems) _items) { auto deleter_thread = ::std::thread([](decltype(topLevelItems) _items) {
for (auto item : _items) for (auto item : _items)
delete item; delete item;
}, ::std::move(topLevelItems)); }, ::std::move(topLevelItems));
deleter_thread.detach(); deleter_thread.detach();
//clear(); //clear();
@ -403,12 +403,12 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
auto hidemenu = menu.addMenu("Select columns"); auto hidemenu = menu.addMenu("Select columns");
auto hdr = headerItem(); auto hdr = headerItem();
for (int i = 0; i < COL_COLUMNS_NUMBER; ++i) for (int i = 0; i < COL_COLUMNS_NUMBER; ++i)
{ {
auto columnAction = new QAction(hdr->text(i), nullptr); auto columnAction = new QAction(hdr->text(i), nullptr);
columnAction->setData(i); columnAction->setData(i);
columnAction->setCheckable(true); columnAction->setCheckable(true);
columnAction->setChecked(!isColumnHidden(i)); columnAction->setChecked(!isColumnHidden(i));
connect(columnAction, &QAction::triggered, this, &This::onHideShowColumn); connect(columnAction, &QAction::triggered, this, &This::onHideShowColumn);
hidemenu->addAction(columnAction); hidemenu->addAction(columnAction);
} }
@ -434,7 +434,7 @@ void EasyTreeWidget::moveEvent(QMoveEvent* _event)
void EasyTreeWidget::alignProgressBar() void EasyTreeWidget::alignProgressBar()
{ {
auto pos = mapToGlobal(rect().center()); auto pos = mapToGlobal(rect().center());
m_progress->move(pos.x() - (m_progress->width() >> 1), pos.y() - (m_progress->height() >> 1)); m_progress->move(pos.x() - (m_progress->width() >> 1), pos.y() - (m_progress->height() >> 1));
} }
@ -694,17 +694,17 @@ void EasyTreeWidget::loadSettings()
void EasyTreeWidget::saveSettings() void EasyTreeWidget::saveSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget"); settings.beginGroup("tree_widget");
settings.setValue("color_rows", m_bColorRows); settings.setValue("color_rows", m_bColorRows);
for (int i = 0; i < columnCount(); i++) for (int i = 0; i < columnCount(); i++)
{ {
settings.setValue(QString("Column") + QString::number(i) , isColumnHidden(i)); settings.setValue(QString("Column") + QString::number(i) , isColumnHidden(i));
} }
settings.endGroup(); settings.endGroup();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -117,7 +117,7 @@ private slots:
protected: protected:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
void alignProgressBar(); void alignProgressBar();
}; // END of class EasyTreeWidget. }; // END of class EasyTreeWidget.

View File

@ -43,8 +43,8 @@
namespace profiler_gui { namespace profiler_gui {
const QString ORGANAZATION_NAME = "EasyProfiler"; const QString ORGANAZATION_NAME = "EasyProfiler";
const QString APPLICATION_NAME = "Easy profiler gui application"; const QString APPLICATION_NAME = "Easy profiler gui application";
const QColor CHRONOMETER_COLOR = QColor::fromRgba(0x402020c0); const QColor CHRONOMETER_COLOR = QColor::fromRgba(0x402020c0);
const QRgb SELECTED_THREAD_BACKGROUND = 0x00e0e060; const QRgb SELECTED_THREAD_BACKGROUND = 0x00e0e060;

View File

@ -39,27 +39,27 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
//QFileSystemModel *model = new QFileSystemModel; //QFileSystemModel *model = new QFileSystemModel;
//model->setRootPath(QDir::currentPath()); //model->setRootPath(QDir::currentPath());
// const char* filename = 0; // const char* filename = 0;
// if(argc > 1 && argv[1]){ // if(argc > 1 && argv[1]){
// filename = argv[1]; // filename = argv[1];
// }else{ // }else{
// return 255; // return 255;
// } // }
// QFile file(filename); // QFile file(filename);
// file.open(QIODevice::ReadOnly); // file.open(QIODevice::ReadOnly);
// TreeModel model(file.readAll()); // TreeModel model(file.readAll());
// file.close(); // file.close();
// QTreeView *tree = new QTreeView(); // QTreeView *tree = new QTreeView();
// tree->setModel(&model); // tree->setModel(&model);
// //
// tree->show(); // tree->show();
auto now = ::std::chrono::duration_cast<std::chrono::seconds>(::std::chrono::system_clock::now().time_since_epoch()).count() >> 1; auto now = ::std::chrono::duration_cast<std::chrono::seconds>(::std::chrono::system_clock::now().time_since_epoch()).count() >> 1;
srand((unsigned int)now); srand((unsigned int)now);

View File

@ -17,20 +17,20 @@
* : * :
* : * * : *
* ----------------- : * ----------------- :
* license : Lightweight profiler library for c++ * license : Lightweight profiler library for c++
* : Copyright(C) 2016 Sergey Yagovtsev, Victor Zarubkin * : Copyright(C) 2016 Sergey Yagovtsev, Victor Zarubkin
* : * :
* : This program is free software : you can redistribute it and / or modify * : This program is free software : you can redistribute it and / or modify
* : it under the terms of the GNU General Public License as published by * : it under the terms of the GNU General Public License as published by
* : the Free Software Foundation, either version 3 of the License, or * : the Free Software Foundation, either version 3 of the License, or
* : (at your option) any later version. * : (at your option) any later version.
* : * :
* : This program is distributed in the hope that it will be useful, * : This program is distributed in the hope that it will be useful,
* : but WITHOUT ANY WARRANTY; without even the implied warranty of * : but WITHOUT ANY WARRANTY; without even the implied warranty of
* : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* : GNU General Public License for more details. * : GNU General Public License for more details.
* : * :
* : You should have received a copy of the GNU General Public License * : You should have received a copy of the GNU General Public License
* : along with this program.If not, see <http://www.gnu.org/licenses/>. * : along with this program.If not, see <http://www.gnu.org/licenses/>.
************************************************************************/ ************************************************************************/
@ -387,10 +387,10 @@ void EasyMainWindow::loadGeometry()
void EasyMainWindow::saveSettingsAndGeometry() void EasyMainWindow::saveSettingsAndGeometry()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("main"); settings.beginGroup("main");
settings.setValue("geometry", this->saveGeometry()); settings.setValue("geometry", this->saveGeometry());
settings.setValue("last_file", m_lastFile); settings.setValue("last_file", m_lastFile);
settings.setValue("chrono_text_position", static_cast<int>(EASY_GLOBALS.chrono_text_position)); settings.setValue("chrono_text_position", static_cast<int>(EASY_GLOBALS.chrono_text_position));
settings.setValue("draw_graphics_items_borders", EASY_GLOBALS.draw_graphics_items_borders); settings.setValue("draw_graphics_items_borders", EASY_GLOBALS.draw_graphics_items_borders);
@ -399,7 +399,7 @@ void EasyMainWindow::saveSettingsAndGeometry()
settings.setValue("bind_scene_and_tree_expand_status", EASY_GLOBALS.bind_scene_and_tree_expand_status); settings.setValue("bind_scene_and_tree_expand_status", EASY_GLOBALS.bind_scene_and_tree_expand_status);
settings.setValue("encoding", QTextCodec::codecForLocale()->name()); settings.setValue("encoding", QTextCodec::codecForLocale()->name());
settings.endGroup(); settings.endGroup();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -127,7 +127,7 @@ private:
void loadSettings(); void loadSettings();
void loadGeometry(); void loadGeometry();
void saveSettingsAndGeometry(); void saveSettingsAndGeometry();
}; // END of class EasyMainWindow. }; // END of class EasyMainWindow.

View File

@ -1,17 +1,17 @@
project(profiler_reader) project(profiler_reader)
set(CPP_FILES set(CPP_FILES
main.cpp main.cpp
) )
set(SOURCES set(SOURCES
${CPP_FILES} ${CPP_FILES}
) )
add_executable(${PROJECT_NAME} ${SOURCES}) add_executable(${PROJECT_NAME} ${SOURCES})
if(UNIX) if(UNIX)
set(SPEC_LIB pthread) set(SPEC_LIB pthread)
endif(UNIX) endif(UNIX)
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB}) target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})

View File

@ -16,57 +16,57 @@
class TreePrinter class TreePrinter
{ {
struct Info{ struct Info{
std::string name; std::string name;
std::string info; std::string info;
}; };
std::vector<Info> m_rows; std::vector<Info> m_rows;
public: public:
TreePrinter(){ TreePrinter(){
} }
void addNewRow(int level) void addNewRow(int level)
{ {
} }
void printTree() void printTree()
{ {
for (auto& row : m_rows){ for (auto& row : m_rows){
std::cout << row.name << " " << row.info << std::endl; std::cout << row.name << " " << row.info << std::endl;
} }
} }
}; };
void printTree(TreePrinter& printer, const ::profiler::BlocksTree& tree, int level = 0, profiler::timestamp_t parent_dur = 0, profiler::timestamp_t root_dur = 0) void printTree(TreePrinter& printer, const ::profiler::BlocksTree& tree, int level = 0, profiler::timestamp_t parent_dur = 0, profiler::timestamp_t root_dur = 0)
{ {
// //
//if (tree.node){ //if (tree.node){
// auto duration = tree.node->block()->duration(); // auto duration = tree.node->block()->duration();
// float duration_ms = duration / 1e6f; // float duration_ms = duration / 1e6f;
// float percent = parent_dur ? float(duration) / float(parent_dur)*100.0f : 100.0f; // float percent = parent_dur ? float(duration) / float(parent_dur)*100.0f : 100.0f;
// float rpercent = root_dur ? float(duration) / float(root_dur)*100.0f : 100.0f; // float rpercent = root_dur ? float(duration) / float(root_dur)*100.0f : 100.0f;
// std::cout << std::string(level, '\t') << tree.node->getName() // std::cout << std::string(level, '\t') << tree.node->getName()
// << std::string(5 - level, '\t') // << std::string(5 - level, '\t')
// /*<< std::string(level, ' ')*/ << percent << "%| " // /*<< std::string(level, ' ')*/ << percent << "%| "
// << rpercent << "%| " // << rpercent << "%| "
// << duration_ms << " ms" // << duration_ms << " ms"
// << std::endl; // << std::endl;
// if (root_dur == 0){ // if (root_dur == 0){
// root_dur = tree.node->block()->duration(); // root_dur = tree.node->block()->duration();
// } // }
//} //}
//else{ //else{
// root_dur = 0; // root_dur = 0;
//} //}
// //
//for (const auto& i : tree.children){ //for (const auto& i : tree.children){
// printTree(printer, i, level + 1, tree.node ? tree.node->block()->duration() : 0, root_dur); // printTree(printer, i, level + 1, tree.node ? tree.node->block()->duration() : 0, root_dur);
//} //}
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -120,9 +120,9 @@ int main(int argc, char* argv[])
std::cout << "Blocks count: " << blocks_counter << std::endl; std::cout << "Blocks count: " << blocks_counter << std::endl;
std::cout << "dT = " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << " usec" << std::endl; std::cout << "dT = " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << " usec" << std::endl;
//for (const auto & i : threaded_trees){ //for (const auto & i : threaded_trees){
// TreePrinter p; // TreePrinter p;
// std::cout << std::string(20, '=') << " thread "<< i.first << " "<< std::string(20, '=') << std::endl; // std::cout << std::string(20, '=') << " thread "<< i.first << " "<< std::string(20, '=') << std::endl;
// printTree(p, i.second.tree,-1); // printTree(p, i.second.tree,-1);
//} //}
if (!dump_filename.empty()) if (!dump_filename.empty())

View File

@ -1,22 +1,22 @@
project(profiler_sample) project(profiler_sample)
set(CPP_FILES set(CPP_FILES
main.cpp main.cpp
) )
set(SOURCES set(SOURCES
${CPP_FILES} ${CPP_FILES}
) )
add_executable(${PROJECT_NAME} ${SOURCES}) add_executable(${PROJECT_NAME} ${SOURCES})
set(DISABLED_PROFILER_NAME set(DISABLED_PROFILER_NAME
"${PROJECT_NAME}_disabled_profiler" "${PROJECT_NAME}_disabled_profiler"
) )
add_executable(${DISABLED_PROFILER_NAME} ${SOURCES}) add_executable(${DISABLED_PROFILER_NAME} ${SOURCES})
if(UNIX) if(UNIX)
set(SPEC_LIB pthread) set(SPEC_LIB pthread)
endif(UNIX) endif(UNIX)
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB}) target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})

View File

@ -26,9 +26,9 @@ void localSleep(int magic=200000)
} }
void loadingResources(){ void loadingResources(){
EASY_FUNCTION(profiler::colors::Darkcyan); EASY_FUNCTION(profiler::colors::Darkcyan);
localSleep(); localSleep();
// std::this_thread::sleep_for(std::chrono::milliseconds(50)); // std::this_thread::sleep_for(std::chrono::milliseconds(50));
} }
void prepareMath(){ void prepareMath(){
@ -37,7 +37,7 @@ void prepareMath(){
for (int i = 0; i < OBJECTS; ++i) for (int i = 0; i < OBJECTS; ++i)
intarray[i] = i * i; intarray[i] = i * i;
delete[] intarray; delete[] intarray;
//std::this_thread::sleep_for(std::chrono::milliseconds(3)); //std::this_thread::sleep_for(std::chrono::milliseconds(3));
} }
void calcIntersect(){ void calcIntersect(){
@ -51,7 +51,7 @@ void calcIntersect(){
intarray[j] = i * j - i / 2 + (OBJECTS - j) * 5; intarray[j] = i * j - i / 2 + (OBJECTS - j) * 5;
} }
delete[] intarray; delete[] intarray;
//std::this_thread::sleep_for(std::chrono::milliseconds(4)); //std::this_thread::sleep_for(std::chrono::milliseconds(4));
} }
double multModel(double i) double multModel(double i)
@ -81,7 +81,7 @@ void calcBrain(){
for (int i = 0; i < OBJECTS; ++i) for (int i = 0; i < OBJECTS; ++i)
intarray[i] = calcSubbrain(i) + double(i * 180 / 3); intarray[i] = calcSubbrain(i) + double(i * 180 / 3);
delete[] intarray; delete[] intarray;
//std::this_thread::sleep_for(std::chrono::milliseconds(3)); //std::this_thread::sleep_for(std::chrono::milliseconds(3));
} }
void calculateBehavior(){ void calculateBehavior(){
@ -92,14 +92,14 @@ void calculateBehavior(){
void modellingStep(){ void modellingStep(){
EASY_FUNCTION(profiler::colors::Navy); EASY_FUNCTION(profiler::colors::Navy);
prepareMath(); prepareMath();
calculateBehavior(); calculateBehavior();
} }
void prepareRender(){ void prepareRender(){
EASY_FUNCTION(profiler::colors::Darkred); EASY_FUNCTION(profiler::colors::Darkred);
localSleep(); localSleep();
//std::this_thread::sleep_for(std::chrono::milliseconds(8)); //std::this_thread::sleep_for(std::chrono::milliseconds(8));
} }
@ -121,168 +121,168 @@ void calculatePhysics(){
for (int i = 0; i < OBJECTS; ++i) for (int i = 0; i < OBJECTS; ++i)
intarray[i] = calcPhysicForObject(i); intarray[i] = calcPhysicForObject(i);
delete[] intarray; delete[] intarray;
//std::this_thread::sleep_for(std::chrono::milliseconds(8)); //std::this_thread::sleep_for(std::chrono::milliseconds(8));
} }
void frame(){ void frame(){
EASY_FUNCTION(profiler::colors::Magenta); EASY_FUNCTION(profiler::colors::Magenta);
prepareRender(); prepareRender();
calculatePhysics(); calculatePhysics();
} }
void loadingResourcesThread(){ void loadingResourcesThread(){
//std::unique_lock<std::mutex> lk(cv_m); //std::unique_lock<std::mutex> lk(cv_m);
//cv.wait(lk, []{return g_i == 1; }); //cv.wait(lk, []{return g_i == 1; });
EASY_THREAD("Resource loading"); EASY_THREAD("Resource loading");
for(int i = 0; i < RESOURCE_LOADING_COUNT; i++){ for(int i = 0; i < RESOURCE_LOADING_COUNT; i++){
loadingResources(); loadingResources();
EASY_EVENT("Resources Loading!", profiler::colors::Cyan); EASY_EVENT("Resources Loading!", profiler::colors::Cyan);
localSleep(1200000); localSleep(1200000);
//std::this_thread::sleep_for(std::chrono::milliseconds(20)); //std::this_thread::sleep_for(std::chrono::milliseconds(20));
} }
} }
void modellingThread(){ void modellingThread(){
//std::unique_lock<std::mutex> lk(cv_m); //std::unique_lock<std::mutex> lk(cv_m);
//cv.wait(lk, []{return g_i == 1; }); //cv.wait(lk, []{return g_i == 1; });
EASY_THREAD("Modelling"); EASY_THREAD("Modelling");
for (int i = 0; i < RENDER_SPEPS; i++){ for (int i = 0; i < RENDER_SPEPS; i++){
modellingStep(); modellingStep();
localSleep(1200000); localSleep(1200000);
//std::this_thread::sleep_for(std::chrono::milliseconds(20)); //std::this_thread::sleep_for(std::chrono::milliseconds(20));
} }
} }
void renderThread(){ void renderThread(){
//std::unique_lock<std::mutex> lk(cv_m); //std::unique_lock<std::mutex> lk(cv_m);
//cv.wait(lk, []{return g_i == 1; }); //cv.wait(lk, []{return g_i == 1; });
EASY_THREAD("Render"); EASY_THREAD("Render");
for (int i = 0; i < MODELLING_STEPS; i++){ for (int i = 0; i < MODELLING_STEPS; i++){
frame(); frame();
localSleep(1200000); localSleep(1200000);
//std::this_thread::sleep_for(std::chrono::milliseconds(20)); //std::this_thread::sleep_for(std::chrono::milliseconds(20));
} }
} }
void four() void four()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
std::this_thread::sleep_for(std::chrono::milliseconds(37)); std::this_thread::sleep_for(std::chrono::milliseconds(37));
} }
void five() void five()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
std::this_thread::sleep_for(std::chrono::milliseconds(20)); std::this_thread::sleep_for(std::chrono::milliseconds(20));
} }
void six() void six()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
std::this_thread::sleep_for(std::chrono::milliseconds(42)); std::this_thread::sleep_for(std::chrono::milliseconds(42));
} }
void three() void three()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
four(); four();
five(); five();
six(); six();
} }
void seven() void seven()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
std::this_thread::sleep_for(std::chrono::milliseconds(147)); std::this_thread::sleep_for(std::chrono::milliseconds(147));
} }
void two() void two()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
std::this_thread::sleep_for(std::chrono::milliseconds(26)); std::this_thread::sleep_for(std::chrono::milliseconds(26));
} }
void one() void one()
{ {
EASY_FUNCTION(profiler::colors::Red); EASY_FUNCTION(profiler::colors::Red);
two(); two();
three(); three();
seven(); seven();
} }
/* /*
one one
two two
three three
four four
five five
six six
seven seven
*/ */
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (argc > 1 && argv[1]){ if (argc > 1 && argv[1]){
OBJECTS = std::atoi(argv[1]); OBJECTS = std::atoi(argv[1]);
} }
if (argc > 2 && argv[2]){ if (argc > 2 && argv[2]){
RENDER_SPEPS = std::atoi(argv[2]); RENDER_SPEPS = std::atoi(argv[2]);
} }
if (argc > 3 && argv[3]){ if (argc > 3 && argv[3]){
MODELLING_STEPS = std::atoi(argv[3]); MODELLING_STEPS = std::atoi(argv[3]);
} }
if (argc > 4 && argv[4]){ if (argc > 4 && argv[4]){
RESOURCE_LOADING_COUNT = std::atoi(argv[4]); RESOURCE_LOADING_COUNT = std::atoi(argv[4]);
} }
std::cout << "Objects count: " << OBJECTS << std::endl; std::cout << "Objects count: " << OBJECTS << std::endl;
std::cout << "Render steps: " << RENDER_SPEPS << std::endl; std::cout << "Render steps: " << RENDER_SPEPS << std::endl;
std::cout << "Modelling steps: " << MODELLING_STEPS << std::endl; std::cout << "Modelling steps: " << MODELLING_STEPS << std::endl;
std::cout << "Resource loading count: " << RESOURCE_LOADING_COUNT << std::endl; std::cout << "Resource loading count: " << RESOURCE_LOADING_COUNT << std::endl;
auto start = std::chrono::system_clock::now(); auto start = std::chrono::system_clock::now();
EASY_PROFILER_ENABLE; EASY_PROFILER_ENABLE;
EASY_MAIN_THREAD; EASY_MAIN_THREAD;
//one(); //one();
//one(); //one();
/**/ /**/
std::vector<std::thread> threads; std::vector<std::thread> threads;
std::thread render = std::thread(renderThread); std::thread render = std::thread(renderThread);
std::thread modelling = std::thread(modellingThread); std::thread modelling = std::thread(modellingThread);
for(int i=0; i < 3; i++){ for(int i=0; i < 3; i++){
threads.emplace_back(std::thread(loadingResourcesThread)); threads.emplace_back(std::thread(loadingResourcesThread));
threads.emplace_back(std::thread(renderThread)); threads.emplace_back(std::thread(renderThread));
threads.emplace_back(std::thread(modellingThread)); threads.emplace_back(std::thread(modellingThread));
} }
{ {
std::lock_guard<std::mutex> lk(cv_m); std::lock_guard<std::mutex> lk(cv_m);
g_i = 1; g_i = 1;
} }
cv.notify_all(); cv.notify_all();
for (int i = 0; i < RENDER_SPEPS; ++i) { for (int i = 0; i < RENDER_SPEPS; ++i) {
modellingStep(); modellingStep();
localSleep(1200000); localSleep(1200000);
} }
render.join(); render.join();
modelling.join(); modelling.join();
for(auto& t : threads){ for(auto& t : threads){
t.join(); t.join();
} }
/**/ /**/
auto end = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now();
auto elapsed = auto elapsed =
std::chrono::duration_cast<std::chrono::microseconds>(end - start); std::chrono::duration_cast<std::chrono::microseconds>(end - start);
std::cout << "Elapsed time: " << elapsed.count() << " usec" << std::endl; std::cout << "Elapsed time: " << elapsed.count() << " usec" << std::endl;
auto blocks_count = profiler::dumpBlocksToFile("test.prof"); auto blocks_count = profiler::dumpBlocksToFile("test.prof");
std::cout << "Blocks count: " << blocks_count << std::endl; std::cout << "Blocks count: " << blocks_count << std::endl;
return 0; return 0;
} }

View File

@ -1,27 +1,27 @@
project(easy_profiler) project(easy_profiler)
set(CPP_FILES set(CPP_FILES
block.cpp block.cpp
profile_manager.cpp profile_manager.cpp
reader.cpp reader.cpp
event_trace_win.cpp event_trace_win.cpp
) )
set(H_FILES set(H_FILES
${ROOT}/include/profiler/profiler.h ${ROOT}/include/profiler/profiler.h
${ROOT}/include/profiler/reader.h ${ROOT}/include/profiler/reader.h
${ROOT}/include/profiler/event_trace_status.h ${ROOT}/include/profiler/event_trace_status.h
profile_manager.h profile_manager.h
spin_lock.h spin_lock.h
event_trace_win.h event_trace_win.h
) )
set(SOURCES set(SOURCES
${CPP_FILES} ${CPP_FILES}
${H_FILES} ${H_FILES}
) )
add_definitions( add_definitions(
-D_BUILD_PROFILER -D_BUILD_PROFILER
) )
add_library(${PROJECT_NAME} SHARED ${SOURCES}) add_library(${PROJECT_NAME} SHARED ${SOURCES})