easy_profiler icon indicating copy to clipboard operation
easy_profiler copied to clipboard

Problem profiling Objective-C++ apps under Xcode

Open pzoltowski opened this issue 5 years ago • 2 comments

I tried use easy profiler to profile c++ code in one of my mac apps without success. I tried to isolate the problem and test with simple hello world and as well with 'profiler_sample' app. Here is what I found out:

  1. My environment is: MacOS Mojave 10.14.4 and Xcode 10.2.1
  2. I can build the project and tested all included samples successfully when built using included cmake script but built the following way instead: cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt/5.12.3/lib/cmake/Qt5Widgets" ... Built librarary I installed to usr/local
macbook:bin patryk$ find /usr/local -iname "*easy_profile*"
/usr/local/lib/cmake/easy_profiler
/usr/local/lib/cmake/easy_profiler/easy_profilerConfig.cmake
/usr/local/lib/cmake/easy_profiler/easy_profilerConfigVersion.cmake
/usr/local/lib/cmake/easy_profiler/easy_profilerTargets-release.cmake
/usr/local/lib/cmake/easy_profiler/easy_profilerTargets.cmake
/usr/local/lib/libeasy_profiler.dylib
  1. ./profiler_sample built with cmake returns good results:
Objects count: 500
Render steps: 1500
Modelling steps: 1500
Resource loading count: 50
Frame time: max 0 us // avg 0 us
Frame time: max 2694 us // avg 2510 us
Frame time: max 2799 us // avg 2505 us
Frame time: max 2787 us // avg 2507 us
Frame time: max 2634 us // avg 2493 us
Frame time: max 2740 us // avg 2491 us
Frame time: max 2612 us // avg 2486 us
Frame time: max 2629 us // avg 2488 us
Elapsed time: 4957592 usec
Blocks count: 6037601
  1. However when I created sample Xcode objective-c++ project with only profiler_sample.cpp profiler doesn't work and doesn't dump any files:
Objects count: 500
Render steps: 1500
Modelling steps: 1500
Resource loading count: 50
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Frame time: max 0 us // avg 0 us
Elapsed time: 5651573 usec
Blocks count: 0

I've added /usr/local/include to Header Search Paths, /usr/local/lib to Library Search Paths and -leasy_profiler to Other Linker Flags

Is there any way to make it work with Xcode projects?

pzoltowski avatar May 19 '19 18:05 pzoltowski

Hello! Thank you for feedback!

Try to add definition for compiler: BUILD_WITH_EASY_PROFILER=1 (do not forget add -D in case of command line)

This macro added by CMake. See docs (section General build system)

yse avatar May 19 '19 20:05 yse

Thanks you. That resolved the issue. Profiler working great!

pzoltowski avatar May 28 '19 18:05 pzoltowski