cygwin环境下gprof+gprof2dot+dot生成函数关系结构图
在linux环境下利用gcc/g编译链接代码的时候,加入-pg选项,在执行文件后就会生成gmon.out,gmon.out记录了函数在cpu运行的时间和被哪些函数调用的次数,关于gprof的使用和原理说明可以参数这两篇文章《linux下的程序分析工具——gprof 》、《Linux性能评测工
在linux环境下利用gcc/g++编译链接代码的时候,加入-pg选项,在执行文件后就会生成gmon.out,gmon.out记录了函数在cpu运行的时间和被哪些函数调用的次数,关于gprof的使用和原理说明可以参数这两篇文章《linux下的程序分析工具——gprof 》、《Linux性能评测工具之一:gprof篇》。步骤如下:
1.gcc -Wall -pg test.c -o test
2../test.exe (由于我是在windows环境下用cygwin的,所以生成有exe后缀)
3.gprof -b ./test.exe >report.txt
生成的flat profile和call graph如图1。
图1
从图1中可以看出gprof生成的都是文字描述,我们可以利用gprof2dot.py脚本把数据转化成dot格式,再利用dot生成一张函数关系图。
cygwin配置环境要求下:
1.安装python。
2.gprof2dot.py(网上有得下载),下载后放在/bin/目录就可以了。
3.安装graphviz,直接搜索graphviz,如图2,然后安装。
图2
gprof2dot默认是部分函数调用图,如果要显示全部的函数调用关系,可以用gprof2dot -n0 -e0。默认的设置可以直接参数gprof2dot.py,截图如图3。
图3
安装好之后,执行如下命令:
gprof -b ./test.exe|gprof2dot.py |dot -Tpng -o test.png或者
python /bin/gprof2dot.py report.txt | dot -Tpng -o test.png
这就生成了一张函数关系图了,如图4。
图4
以上都是今天下午的学习成果,总结了网上一些文章所说的和自己动手实践成果。但是我一点都不懂graphviz和dot,这是值得我拓展的地方!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

In this article, we will learn about the differences between Python and Anaconda. What is Python? Python is an open source language that places great emphasis on making the code easy to read and understand by indenting lines and providing whitespace. Python's flexibility and ease of use make it ideal for a variety of applications, including but not limited to scientific computing, artificial intelligence, and data science, as well as creating and developing online applications. When Python is tested, it is immediately translated into machine language because it is an interpreted language. Some languages, such as C++, require compilation to be understood. Proficiency in Python is an important advantage because it is very easy to understand, develop, execute and read. This makes Python

Windows Subsystem for Linux The first option is to use Windows Subsystem for Linux or WSL, which is a compatibility layer for running Linux binary executables natively on Windows systems. It works for most scenarios and allows you to run shell scripts in Windows 11/10. WSL is not automatically available, so you must enable it through your Windows device's developer settings. You can do this by going to Settings > Update & Security > For Developers. Switch to developer mode and confirm the prompt by selecting Yes. Next, look for W

PHP integrated environment packages include: 1. PhpStorm, a powerful PHP integrated environment; 2. Eclipse, an open source integrated development environment; 3. Visual Studio Code, a lightweight open source code editor; 4. Sublime Text, a A popular text editor, widely used in various programming languages; 5. NetBeans, an integrated development environment developed by the Apache Software Foundation; 6. Zend Studio, an integrated development environment designed for PHP developers.

Setting environment variables on Windows 11 can help you customize your system, run scripts, and configure applications. In this guide, we'll discuss three methods along with step-by-step instructions so you can configure your system to your liking. There are three types of environment variables System environment variables – Global variables are the lowest priority and are accessible to all users and applications on Windows and are typically used to define system-wide settings. User Environment Variables – Higher priority, these variables only apply to the current user and process running under that account, and are set by the user or application running under that account. Process environment variables – have the highest priority, they are temporary and apply to the current process and its sub-processes, providing the program

Common problems and solutions for Laravel environment configuration file .env When using the Laravel framework to develop projects, the environment configuration file .env is very important. It contains key configuration information of the project, such as database connection information, application keys, etc. However, sometimes there are some common problems when configuring the .env file. This article will introduce these problems and provide solutions, and attach specific code examples for reference. Problem 1: Unable to read the .env file when we have configured the .env file

Go language environment configuration method: 1. Download the go language compiler and double-click to run the installation program; 2. Accept the license agreement and click next; 3. Set the installation directory and click OK; 4. After the installation is completed, change the go installation directory Just add the bin directory to the environment variable.

The difference and connection between the pipenv environment and the virtual environment requires specific code examples. With the increasing popularity of Python, more and more developers are using virtual environments in Python projects to isolate the dependent libraries of different projects. The virtual environment can ensure that the Python libraries and their versions that the project depends on are properly managed to avoid various conflicts and version inconsistencies. However, in the past, using virtual environments required third-party libraries such as virtualenv and virtualenvwrapper. soon
