当前位置:网站首页>Unity game optimization - third edition reading notes Chapter 1 analyze performance problems
Unity game optimization - third edition reading notes Chapter 1 analyze performance problems
2022-04-22 02:17:00 【Eggbreaker2077】
Chapter 1 Analyze performance issues
Catalog
Use Unity Profiler get data
- Connection on device profile, The data are not entirely accurate
- because Development Mode and connection Unity profile Lead to CPU The load increases and the memory increases greatly . If you run in some large projects , It will cause memory overflow , The script does not run , Physical effects stop update , etc.
- To avoid some of the above , We're going to use benchmarking( Benchmarking analysis ): At some switching points , Pay attention to a period of time when the performance becomes significantly worse .
- Editor Medium Profile The data is not reliable , It needs to be used in the real machine .
Profile Remote connection iOS
Be careful : Connect iOS Equipment time ,Unity Must be in Mac Machine running
- When the packaging Development Build and Autoconnect Profiler tick
- The computer and mobile phone are connected to the same local network WiFi
- use usb Connect your phone to mac The computer
- pack
- stay Unity Open in Profiler, And then choose iOS equipment
If there is still a problem with the connection , Check here :https://docs.unity3d.com/Manual/TroubleShootingIPhone.html
Profile Remote connection Android
and iOS be similar .
If there's a problem with the connection , Check here :[https://docs.unity3d.com/Manual/TroubleShootingAndroid. html](https://docs.unity3d.com/Manual/TroubleShootingAndroid. html)
Deep Profile
You can see almost all the calling methods . But it costs a lot .
Allocation Callstack (2019 above )
Activate Call Stacks After button , In an open DeepProfile Under the circumstances .Profiler It will also collect more memory allocation problems .
And then through Show Related Objects Button , We can see the call stack .

Performance analysis Check List
- Verify that the target script appears in the scene
- Verify that the target script appears correctly
- Verify the correct sequence of events
- Minimize ongoing code changes
- Minimize internal interference
- Minimize external interference
Custom script analysis
Use stopwatch Class to create a timing tool :
using System.Diagnostics;
public class CustomTimer : IDisposable {
private string _timerName;
private int _numTests;
private Stopwatch _watch;
// give the timer a name, and a count of the
// number of tests we're running
public CustomTimer(string timerName, int numTests) {
_timerName = timerName;
_numTests = numTests;
if (_numTests <= 0) {
_numTests = 1;
}
_watch = Stopwatch.StartNew();
}
// automatically called when the 'using()' block ends
public void Dispose() {
_watch.Stop();
float ms = _watch.ElapsedMilliseconds;
UnityEngine.Debug.Log(string.Format("{0} finished: {1:0.00} " +
"milliseconds total, {2:0.000000} milliseconds per-test " +
"for {3} tests", _timerName, ms, ms / _numTests, _numTests));
}
}
Examples of use :
const int numTests = 1000;
using (new CustomTimer("My Test", numTests)) {
for(int i = 0; i < numTests; ++i) {
TestFunction();
}
} // After execution timer's Dispose() Will be called
版权声明
本文为[Eggbreaker2077]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220216054555.html
边栏推荐
- Advanced file IO of system programming (12) -- blocking and non blocking reading
- Analysis and interpretation of the current situation and challenges faced by enterprise operation and maintenance in the digital era
- 【项目】小帽外卖(七)
- How to select the appropriate neo4j Version (2022)
- Introduction to Matlab (I)
- Ezreal--将一个动画切割为四动作动画成功---New Unity Project (3).
- Leetcode 203. Remove linked list elements
- Time and current time judgment in MySQL database
- flutter 不用状态栏的导航栏
- Evaluation of arithmetic four mixed operation expression
猜你喜欢

2022年软件设计师考试知识点:线性表

Ultimate doll 2.0 | observable practice sharing of cloud native PAAS platform

Jetcode prize essay solicitation activity | interesting stories of low code industry waiting for you to share

Nacos 为什么这么强
![[timing] reformer: local sensitive hash (LSH) to achieve efficient transformer paper notes](/img/8a/2214bb4f8595ac2d0871cb2c190f00.png)
[timing] reformer: local sensitive hash (LSH) to achieve efficient transformer paper notes

Page 78 digital twin + smart building solutions

Information Security Overview

Basic operation of MySQL database ------ (basic addition, deletion, query and modification)

QT program is packaged into an EXE executable file

Page 49 information planning and digital transformation of petroleum and petrochemical industry
随机推荐
Page 78 digital twin + smart building solutions
DEJA_ Vu3d - cesium feature set 012 - military plotting Series 6: Custom polygons
Profiteering method of blind box project
Leetcode 567. Arrangement of strings
Detailed explanation of 8 common SQL errors in MySQL
Raspberry pie 4B 8g installation log (3) - Programming Environment
Nacos 为什么这么强
MySQL cannot find my INI file
Golang 中 select 语句死锁问题
Introduction to Alibaba's super large-scale Flink cluster operation and maintenance system
(counting line segment tree) lintcode medium 248 · count the number of numbers smaller than a given integer
Analyticdb PostgreSQL's new version of cloud native allows users to focus on business. What kind of experience upgrade does it achieve?
Leetcode 386. Number of dictionary rows
MySQL modifies a field to auto increment
像堆乐高一样解释神经网络的数学过程
Evaluation of arithmetic four mixed operation expression
golang 1.8泛型测试
GreenDao的使用;
信息安全概述
Review of SV knowledge points