Skip to content

Commit

Permalink
update: update note gperf tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hxf0223 committed Jun 24, 2024
1 parent d23716a commit 5765a5d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions _posts/2024-06-21-gperf-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ endif()
```cmake
if(ENABLE_PROFILER)
message(STATUS "enable profiler")
target_compile_options(${target_test} PRIVATE -pg -fno-omit-frame-pointer)
target_link_options(${target_test} PRIVATE -pg -fno-omit-frame-pointer)
target_compile_options(${target_test} PRIVATE -fno-omit-frame-pointer)
target_link_options(${target_test} PRIVATE -fno-omit-frame-pointer)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
# set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer")
endif()
Expand All @@ -62,6 +62,15 @@ CPUPROFILE=test_flow_benchmark.prof CPUPROFILE_FREQUENCY=500 ./test --gtest_filt
pprof --pdf ./server server.prof > perf.pdf
```

## 4. 使用 GNU gprof 分析程序性能

```cmake
target_compile_options(${target_test} PRIVATE -pg -g)
target_link_options(${target_test} PRIVATE -pg -g)
```

gprof 不支持多线程应用,多线程下只能采集主线程性能数据。多线程需要重写`pthread_create()`。参考:[Linux性能优化gprof使用](https://www.cnblogs.com/youxin/p/7988479.html)

## 参考

1. [gperftools](https://github.com/gperftools/gperftools)
Expand Down

0 comments on commit 5765a5d

Please sign in to comment.