《游戏引擎架构》笔记2:专业工具
本文是阅读《游戏引擎架构》第二章"专业工具”进行的归纳和总结,部分内容经过了AI的扩展。
-
版本管理:常用的有Git、SVN等。
-
不同的编译器的宏
- MSVC:
_MSC_VER - GCC:
__GNUC__ - Clang:
__clang__ - MinGW / MinGW-w64 :
__MINGW32__/__MINGW64__
- 不同平台的宏
- Windows32 / Windows64:
_WIN32/_WIN64 - Linux / Unix:
__linux__/__unix__ - macOS:
__APPLE__
-
关闭内联函数展开,函数只有一个地址,方便追踪调试。
-
调试时,可执行文件链接调试用的库,发布版本则链接优化的库。也可以设置混合模式,一部分代码为调试模式,其余代码优化全速运行。
-
Visual Studio显示数据的方式(watch功能):
,d后缀强制把值以十进制数显示。,x后缀强制把值以十六进制数显示。,n后缀 (n为任意正整数)强制Visual Studio把该值视为一个有n个元素的数组。此后缀可以用来展开以指针参考的数组数据。可能速度变慢。
- 游戏引擎性能剖析器(更多参考List of performance analysis tools-Wikipedia)
- 统计式采样剖析器(采样Profiler,不修改代码、低侵入、随机采样调用栈)
- Windows Performance Recorder/WPA:Windows
- SimplePerf:Android、Linux
- Instruments(Time Profiler):macOS、iOS
- gprof(Linux简易采样):Linux
- Unity Profiler 主线采样分析:Windows、Android、iOS、主机全平台
- 测控式(插桩)剖析器(Instrumented,埋点统计、精准耗时、开销较高)
- Unity Profiler 自定义Marker、CPU Detailed:全主机/移动端/PC
- Unreal Insights:Windows、主机、移动端
- VTune(Intel 插桩+采样双模式):Windows、Linux
- Telemetry SDK / Xbox PIX:Xbox主机、Windows
- RenderDoc、Graphics Profiler(GPU插桩时序):PC、安卓、主机
- Tracy Profiler:Windows、Linux、Android、跨引擎自研引擎
- 内存泄露
-
C/C++ 原生
- Valgrind (Memcheck):Linux、macOS
- AddressSanitizer (ASan):Linux、macOS、Windows (MSVC/Clang)
- Visual Leak Detector (VLD):Windows (Visual Studio)
- Dr. Memory:Windows、Linux
- CRT Debug Heap:Windows (MSVC)
- mtrace:Linux (glibc)
- gperftools (tcmalloc):Linux、macOS
- heaptrack:Linux
- Rational Purify: Windows、Linux
- Bounds Checker3:Windows
-
Java / JVM
- Eclipse MAT:Windows、Linux、macOS
- VisualVM:Windows、Linux、macOS
- JProfiler:Windows、Linux、macOS
- YourKit Java Profiler:Windows、Linux、macOS
- JConsole:Windows、Linux、macOS
- Java Flight Recorder (JFR):Windows、Linux、macOS
-
Go
- pprof:Windows、Linux、macOS
- go trace:全平台
-
Python
- tracemalloc:全平台(内置)
- objgraph:全平台
- memory_profiler:全平台
- py-spy:全平台
-
JavaScript / Node.js
- Chrome DevTools Memory:全平台(浏览器)
- Node.js Inspector / --inspect:全平台
- clinic.js:全平台
- memwatch-next:全平台
-
.NET / C#
- Visual Studio Memory Profiler:Windows
- dotMemory:Windows、Linux、macOS
- CLR Profiler:Windows
-
iOS / macOS (Obj-C/Swift)
- Xcode Memory Graph Debugger:macOS
- Instruments (Leaks):macOS
-
Android
- Android Studio Profiler:Windows、Linux、macOS
- LeakCanary:Android(库)
- 其他工具:
- 区别工具:
- ExamDiff
- Araxis-Merge
- WinDiff
- GNU区别工具包
- 三路合并工具:
- Araxis-Merge
- WinMerge
- Perforce
- 十六进制编辑器:
- HexEdit