码迷,mamicode.com
首页 > 编程语言 > 详细

ubuntu上编译和使用easy_profiler对C++程序进行性能分析

时间:2019-12-11 09:32:42      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:pos   性能分析   tar   nta   get   with   clu   pac   tip   

本文首发于个人博客https://kezunlin.me/post/91b7cf13/,欢迎阅读最新内容!

tutorial to compile and use esay profiler with c++ on ubuntu 16.04

Guide

compile

git clone https://github.com/yse/easy_profiler.git
cd easy_profiler && mkdir build && cd build && cmake-gui ..

make -j8

sudo make install

usage

CMakeLists.txt

find_package(easy_profiler REQUIRED)
#easy_profiler_Dir /usr/local/lib/cmake/easy_profiler

target_link_libraries(my_application easy_profiler) 

code

#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
}

Reference

History

  • 20191010: created.

Copyright

ubuntu上编译和使用easy_profiler对C++程序进行性能分析

标签:pos   性能分析   tar   nta   get   with   clu   pac   tip   

原文地址:https://www.cnblogs.com/kezunlin/p/12020202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!