この記事では、最初の個人的なブログ登場https://kezunlin.me/post/91b7cf13/最新の内容に、ようこそ!
Ubuntuの16.04でのC ++でesayプロファイラをコンパイルして使用するためのチュートリアル
ガイド
コンパイル
git clone https://github.com/yse/easy_profiler.git
cd easy_profiler && mkdir build && cd build && cmake-gui ..
make -j8
sudo make install
使用法
CMakeLists.txt
find_package(easy_profiler REQUIRED)
#easy_profiler_Dir /usr/local/lib/cmake/easy_profiler
target_link_libraries(my_application easy_profiler)
コード
#include <easy/profiler.h>
void foo() {
EASY_FUNCTION(profiler::colors::Magenta); // Magenta block with name "foo"
EASY_BLOCK("Calculating sum"); // Begin block with default color == Amber100
int sum = 0;
for (int i = 0; i < 10; ++i) {
EASY_BLOCK("Addition", profiler::colors::Red); // Scoped red block (no EASY_END_BLOCK needed)
sum += i;
}
EASY_END_BLOCK; // End of "Calculating sum" block
EASY_BLOCK("Calculating multiplication", profiler::colors::Blue500); // Blue block
int mul = 1;
for (int i = 1; i < 11; ++i)
mul *= i;
//EASY_END_BLOCK; // This is not needed because all blocks are ended on destructor when closing braces met
}
void bar() {
EASY_FUNCTION(0xfff080aa); // Function block with custom ARGB color
}
void baz() {
EASY_FUNCTION(); // Function block with default color == Amber100
}
参照
歴史
- 20191010:作成しました。
著作権
- 投稿者:kezunlin
- ポストリンク:https://kezunlin.me/post/91b7cf13/
- 著作権:別途明記しない限り、このブログのすべての記事はCC BY-NC-SA 3.0の下でライセンスされています。