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

本文首发于个人博客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

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

时间: 2024-08-29 13:38:02

ubuntu上编译和使用easy_profiler对C++程序进行性能分析的相关文章

【转】Ubuntu 上编译Android出现cannot find -lstdc++解决办法

[转]Ubuntu 上编译Android出现cannot find -lstdc++解决办法 在Ubuntu 12.04 x86_64机器上编译Android出现下面错误,是因为找不到32bit的libstdc++.so库. /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incom

.NET跨平台:在Linux Ubuntu上编译coreclr/corefx/dnx(20150617)

编译时间:北京2015年6月17日上午 操作系统:Ubuntu 14.04.2 LTS Mono版本:Mono JIT compiler version 4.3.0 (master/3445ac5 Tue Jun 16 20:43:48 CST 2015) 一.编译coreclr 成功! Repo successfully built. Product binaries are available at /data/git/coreclr/bin/Product/Linux.x64.Debug

在Linux Ubuntu上编译DNX

DNX是.NET Execution Environment,前身是XRE,XRE的前身是KRuntime,项目网址:https://github.com/aspnet/DNX . 签出DNX的代码: git clone https://github.com/aspnet/DNX.git --recursive 安装Mono: apt-get install mono-complete 运行./build.sh命令进行编译,出现错误: WARNING: Invalid certificate r

在Windows7和Ubuntu上编译安装MICO

MICO是CORBA标准的一个实现.开源并且被广泛使用. 首先的首先,看用户手册,在页面"http://www.mico.org/docu.html"找到一本教材"MICO: An Open Source CORBA Implementation",去Google搜一下,有PDF下载 然后,选择一个正确的下载包 打开www.mico.org,点击"download" 可以看到下图所示 这里不要去选择第一项"Complete source

在ubuntu上编译chrome

红心地瓜 1.获取代码 1)下载tarball,http://chromium-browser-source.commondatastorage.googleapis.com/chromium_tarball.html 2)   解压缩 3)安装dept_tools: http://www.chromium.org/developers/how-tos/install-depot-tools 将dept_tools加到PATH里面 export PATH="$PATH":`pwd`/d

菜鸟起飞:第一次在ubuntu上编译android源码

算一算自己干android开发,还差那么几个月就要满两年了,可是自己连android源码都没有编译过一次,想想真是说不过去,就想想编译一次,中间还真是遇见了不少的问题,在此写一篇博客供大家参考. 切记:每个人的环境都不相同,可能我的编译过程可以成功,但是对于你的就不成功,在遇到问题的时候要具体对待,具体解决,关键就在于恒心与毅力. -----------------------------------------------------------------------------------

ubuntu上编译安装R

1.在下载R的源码包 我下载的是这个版本   R-2.15.3.tar.gz 2.解压 我的文件在/home/vobile目录下,也解压在一个/home/obile 目录下 cd /home/obile tar -xf   R-2.15.3.tar.gz 3.编译安装 cd cd R-2.15.3/ ./configure --prefix=./configure --prefix=/home/liyistat/Desktop/R-3.0.2 --enable-R-shlib 其中 --pref

ubuntu上部署windows开发的dotnet core程序

目标:完成windows上开发的dotnet core程序部署至linux服务器上(Ubuntu 14.04) windows上开发dotnet core很简单,安装好VS2017,建立相关类型的项目进行开发即可. Linux服务器中需要做以下几个工作: 1.安装dotnet core, 运行dotnet程序必备条件. 2.安装supervisor守护进程,可以帮助你自动启动站点. 3.安装nginx做代理 1. 安装dotnet core #依次执行下面的命令,安装的版本有问题的话,按照错误提

在Ubuntu上为Android系统内置Java应用程序测试Application Frameworks层的硬件服务(老罗学习笔记)

一:Eclipse下 1.创建工程: ---- 2.创建后目录 3.添加java函数 4.在src下创建package,在package下创建file 5.res---layout下创建xml文件,命名main 6.project下清楚错误 7.位解决错误 ① ② 8.总体目录 9.当删除工程后,可以import再重新导入工程. 二:源码下 ① 将Hello目录拷贝至packages/experimental目录,新增Android.mk文件:    [email protected]:~/An