Browse Source

Added Tracy profiler

The module is still WIP. Some build system changes are necessary to
make it sufficiently convenient
master
Macoy Madson 2 months ago
parent
commit
0bded8b046
6 changed files with 60 additions and 0 deletions
  1. +3
    -0
      .gitmodules
  2. +4
    -0
      BuildTools.sh
  3. +1
    -0
      Build_Debug.sh
  4. +1
    -0
      Dependencies/tracy
  5. +3
    -0
      RunProfiler.sh
  6. +48
    -0
      src/Tracy.cake

+ 3
- 0
.gitmodules View File

@ -7,3 +7,6 @@
[submodule "Dependencies/ogre-next-deps"]
path = Dependencies/ogre-next-deps
url = https://github.com/OGRECave/ogre-next-deps
[submodule "Dependencies/tracy"]
path = Dependencies/tracy
url = https://github.com/wolfpld/tracy

+ 4
- 0
BuildTools.sh View File

@ -0,0 +1,4 @@
#!/bin/sh
# These are things not required to build, but are useful for debugging/profiling etc.
cd Dependencies/tracy/profiler/build/unix && make -j4

+ 1
- 0
Build_Debug.sh View File

@ -7,3 +7,4 @@
# ./Dependencies/cakelisp/bin/cakelisp --verbose-processes src/SDL.cake
./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects test/SDLOgreApp.cake \
&& echo "\n\nRUNTIME\n" && cd test && ./SDLOgreApp
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects src/Tracy.cake

+ 1
- 0
Dependencies/tracy

@ -0,0 +1 @@
Subproject commit e580dfeed3f44911cf0a5ce0f584603aafa9ecde

+ 3
- 0
RunProfiler.sh View File

@ -0,0 +1,3 @@
#!/bin/sh
cd Dependencies/tracy/profiler/build/unix && ./Tracy-release

+ 48
- 0
src/Tracy.cake View File

@ -0,0 +1,48 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(import &comptime-only "Macros.cake")
(c-import "Tracy.hpp")
;; TODO: Linux only
(c-import "unistd.h")
(defun test-tracy-main (&return int)
(ZoneScopedN "main")
(while (not (on-call (call (in tracy GetProfiler)) IsConnected))
(ZoneScopedN "wait for profiler")
(sleep 1))
(var i int 0)
(while (< i 100000)
(ZoneScopedN "hot loop")
(sleep 1)
(incr i))
(return 0))
;; TODO: Any file which includes Tracy needs these
;; For now, an easy way to build files which include necessary headers
(defmacro module-use-tracy-build-options ()
(tokenize-push output
(set-module-option build-time-compiler "/usr/bin/clang++")
;; Include cakelisp source for DynamicLoader.hpp
(set-module-option build-time-compile-arguments
"-Werror" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wno-unused-variable"
"-c" 'source-input "-o" 'object-output "-fPIC"
"-DTRACY_ENABLE" "-IDependencies/tracy"))
(return true))
(module-use-tracy-build-options)
(add-cpp-build-dependency "../Dependencies/tracy/TracyClient.cpp")
(defun-comptime tracy-link-hook (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
(command-add-string-argument "-lpthread")
(command-add-string-argument "-ldl")
(return true))
(add-compile-time-hook pre-link tracy-link-hook)

Loading…
Cancel
Save