Unity3D性能消耗分析器文档格式.docx

上传人:b****4 文档编号:7928987 上传时间:2023-05-09 格式:DOCX 页数:14 大小:600.21KB
下载 相关 举报
Unity3D性能消耗分析器文档格式.docx_第1页
第1页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第2页
第2页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第3页
第3页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第4页
第4页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第5页
第5页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第6页
第6页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第7页
第7页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第8页
第8页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第9页
第9页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第10页
第10页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第11页
第11页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第12页
第12页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第13页
第13页 / 共14页
Unity3D性能消耗分析器文档格式.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Unity3D性能消耗分析器文档格式.docx

《Unity3D性能消耗分析器文档格式.docx》由会员分享,可在线阅读,更多相关《Unity3D性能消耗分析器文档格式.docx(14页珍藏版)》请在冰点文库上搜索。

Unity3D性能消耗分析器文档格式.docx

Notethatprofilinghastoinstrumentyourcode.Thisinstrumentationhasasmallimpactontheperformanceofyourgame.Typicallythisoverheadissmallenoughtonotaffectthegameframerate.Whenusingprofilingitistypicaltoconsideronlytheratio(orpercentage)oftimespentincertainareas.Also,toimproveperformancefocusonthosepartsofthegamethatconsumethemosttime.Compareprofilingresultsbeforeandaftercodechangesanddeterminetheimprovementsyoumeasure.Sometimeschangesyoumaketoimproveperformancemighthaveanegativeeffectonframerate;

unexpectedconsequencesofcodeoptimizationshouldbeexpected.

请注意,分析时必须检测你的代码。

这检测会对你的游戏性能有小小影响。

通常情况下,这种开销是足够小,不会影响游戏的帧率。

当使用分析时,它是典型的考虑时间花费在某些领域的比例(或百分比)。

此外,为了提高性能,重点在游戏消耗的时间最多的那些部分。

代码更改前后比较分析结果,并确定您测量的改进。

有时,您所做的更改来提高性能,可能对帧速率有负面影响;

应预计代码优化的意外的后果。

Profilerwindow

AttachingtoUnityplayers附加到Unity播放器

Toprofileyourgamerunningonanotherdeviceoraplayerrunningonanothercomputer,itispossibletoconnecttheeditortothatotherplayer.ThedropdownActiveProfilerwillshowallplayersrunningonthelocalnetwork.Theseplayersareidentifiedbyplayertypeandthehostnamerunningtheplayer"

iPhonePlayer(TomsiPhone)"

.Tobeabletoconnecttoaplayer,theplayermustbelaunchedwiththeDevelopmentBuildcheckboxfoundintheBuildSettingsdialog.FromhereitisalsopossibletotickacheckboxtomaketheEditorandPlayerAutoconnectatstartup.

要分析你的游戏运行在其他设备上或者在另一台计算机上运行的播放器,可以连接编辑器到其他播放器。

ActiveProfiler下拉菜单显示在本地网络上运行的所有播放器。

这些播放器通过播放器的类型和运行播放器的主机名"

iPhonePlayer(TomsiPhone)"

被识别。

要能够连接到一个播放器,播放器必须在BuildSettings对话框中找到DevelopmentBuild复选框勾上的情况下打包生成。

从这里也可以勾选一个复选框,使编辑器和播放器在启动时自动连接。

ProfilerControls分析器控件

Profilercontrolsareinthetoolbaratthetopofthewindow.Usethesetoturnprofilingonandoff,navigatethroughprofiledframesandsoon.Thetransportcontrolsareatthefarrightendofthetoolbar.Notethatwhenthegameisrunningandtheprofileriscollectingdataclickingonanyofthesetransportcontrolswillpausethegame.Thecontrolsgotothefirstrecordedframe,steponeframeback,steponeframeforwardandgotothelastframerespectively.Theprofilerdoesnotkeepallrecordedframes,sothenotionofthefirstframeshouldreallybethoughofastheoldestframethatisstillkeptinmemory.The"

current"

transportbuttoncausestheprofilestatisticswindowtodisplaydatacollectedinreal-time.TheActiveProfilerpopupmenuallowsyoutoselectwhetherprofilingshouldbedoneintheeditororaseparateplayer(forexample,agamerunningonanattachediOSdevice).

分析器控件在窗口顶部的工具栏。

使用这些控件打开和关闭分析,浏览分析好的帧等。

传输控件在工具栏的最右端。

请注意,当游戏运行、分析器收集数据时,点击任何这些传输控件(那两个小箭头)将暂停游戏。

控件转到记录的第一帧,一步一帧向前(左箭头)​​,一步一帧向后(右箭头),分别去到最后一帧。

分析器不保留所有记录的帧,因此第一帧的概念,事实上应该是仍然保存在内存中的最旧的一帧。

"

按钮会使得分析统计窗口显示实时采集的数据。

激活分析器(ActiveProfiler)弹出菜单让你选择是否应在编辑器或一个或独立播放器进行分析(例如,一个游戏运行在iOS设备)。

DeepProfiling深度分析

WhenyouturnonDeepProfile,allyourscriptcodeisprofiled-thatis,allfunctioncallsarerecorded.Thisisusefultoknowwhereexactlytimeisspentinyourgamecode.

当你打开深度分析(DeepProfile),所有脚本代码将被分析-也就是说,所有的函数调用被记录。

知道确切在你的游戏代码中花费的时间,这是有用的。

NotethatDeepProfilingincursaverylargeoverheadandusesalotofmemory,andasaresultyourgamewillrunsignificantlyslowerwhileprofiling.Ifyouareusingcomplexscriptcode,DeepProfilingmightnotbepossibleatall.Deepprofilingshouldworkfastenoughforsmallgameswithsimplescripting.IfyoufindthatDeepProfilingforyourentiregamecausestheframeratetodropsomuchthatthegamebarelyruns,youshouldconsidernotusingthisapproach,andinsteadusetheapproachdescribedbelow.Youmayfinddeepprofilingmorehelpfulasyouaredesigningyourgameanddecidinghowtobestimplementkeyfeatures.NotethatforlargegamesdeepprofilingmaycauseUnitytorunoutofmemoryandsoforthisreasondeepprofilingmaynotbepossible.

注意深度分析(DeepProfiling)会造成非常大的开销,并使用大量的内存,结果你的游戏在分析同时运行明显变慢。

如果您使用的是复杂的脚本代码,深度分析可能不会完全有效。

深度分析为使用简单的脚本的小游戏工作足够快。

如果您发现您的整个游戏在深度分析时运行,导致帧速率下降很多,以至于游戏几乎不能运行,你应该考虑不采用这种方法,而是使用下面描述的方法。

您可能会发现深度分析更有利于设计你的游戏,并确定如何最好地实现关键特性。

注意深度分析,对于大型游戏可能会导致Unity耗尽内存,基于这个原因,深度分析未必有效。

ManuallyprofilingblocksofyourscriptcodewillhaveasmalleroverheadthanusingDeepProfiling.UseProfiler.BeginSampleandProfiler.EndSamplescriptingfunctionstoenableanddisableprofilingaroundsectionsofcode.

手动分析脚本代码块比使用深度分析产生更小的开销。

使用Profiler.BeginSample和Profiler.EndSample函数,启用和禁用分析代码段(从Profiler.BeginSample到Profiler.EndSample间的代码)。

ViewSyncTime查看SyncTime

Whenrunningatafixedframerateorrunninginsyncwiththeverticalblank,Unityrecordsthewaitingtimein"

WaitForTargetFPS"

.Bydefaultthisamountoftimeisnotshownintheprofiler.Toviewhowmuchtimeisspentwaiting,youcantoggle"

ViewSyncTime"

.Thisisalsoameasureofhowmuchheadroomyouhavebeforelosingframes.

当运行在一个固定的帧率或带垂直空白同步运行,Unity在"

记录等待时间,默认情况下,该段时间没有显示在分析器。

要查看等待花费多少时间,您可以切换"

这也是衡量多少余量你之前丢失帧。

ProfilerTimeline分析器时间轴

TheupperpartoftheProfilerwindowdisplaysperformancedataovertime.Whenyourunagame,dataisrecordedeachframe,andthehistoryofthelastseveralhundredframesisdisplayed.Clickingonaparticularframewilldisplayit'

sdetailsinthelowerpartofthewindow.Differentdetailsaredisplayeddependingonwhichtimelineareaiscurrentlyselected.

分析器窗口的上部显示随着时间的推移的性能数据。

当您运行游戏,每一帧数据被记录,最后则会显示几百帧的历史。

点击一个特定的帧上,该帧的细节将显示在窗口的下部。

具体取决于当前选定的时间轴区域显示不同的细节。

Theverticalscaleofthetimelineismanagedautomaticallyandwillattempttofilltheverticalspaceofthewindow.NotethattogetmoredetailinsaytheCPUUsageareayoucanremovetheMemoryandRenderingareas.Also,thesplitterbetweenthetimelineandthestatisticsareacanbeselectedanddraggeddownwardtoincreasethescreenareausedforthetimelinechart.

时间轴的垂直刻度是自动管理,并尝试填补窗口的垂直空间。

请注意,要获得更多关于CPU的使用率(CPUUsage)的细节,您可以删除内存(Memory)和渲染(Rendering)区域。

此外,时间轴和统计区域之间的分离器能被选择和向下拖动,为时间轴图表增加屏幕面积。

Thetimelineconsistsofseveralareas:

CPUUsage,RenderingandMemory.Theseareascanberemovedbyclickingtheclosebuttoninthepanel,andre-addedagainusingtheAddAreadropdownintheProfileControlsbar.

时间轴包括几个方面:

CPU使用率,渲染和内存。

这些区域可以在面板上按一下关闭按钮删除和在分析控件(ProfileControls)工具栏中使用AddArea下拉菜单再次重新添加。

CPUUsageArea(CPU使用率区域)

TheCPUUsageareadisplayswheretimeisspentinyourgame.Whenitisselected,thelowerpanedisplayshierarchicaltimedatafortheselectedframe.

CPU使用率区域显示你的游戏在哪里花费时间。

当这个区域被选中,下部窗格中显示选定的帧层次化的时间数据。

∙Hierarchymode:

Displayshierarchicaltimedata.

层级模式(Hierarchymode):

显示层次化的时间数据。

∙GroupHierarchymode:

Groupstimedataintologicalgroups(Rendering,Physics,Scriptsetc.).Becausechildrenofanygroupcanbeindifferentgroup(e.g.somescriptmightcallrenderingfunctions),thepercentagesofgrouptimesoftenadduptomorethan100%.(Thisisnotabug.)

组层级模式(GroupHierarchymode):

成逻辑组的组时间数据(渲染(Rendering),物理(Physics),脚本(Scripts)等)。

因为任何组的子成员,可在不同的组(例如一些脚本可能调用渲染功能),组时间的百分比往往加起来超过100%。

(这不是一个错误。

ThewaytheCPUchartisstackedcanbereorderedbysimplydraggingchartlabelsup&

down.

CPU的使用率(CPUUsage)图表堆叠方式,可以通过简单的上下拖动图表标签进行重新排序。

Whenanitemisselectedinthelowerpane,it'

scontributiontotheCPUchartishighlighted(andtherestaredimmed).Clickingonanitemagainde-selectsit.

当在下部窗格中选择一个项目,对应到CPU的使用率(CPUUsage)图表上会高亮显示(和其余部分为灰色)。

再次点击这个项目就会取消选择。

Shader.SetPassisselectedandit'

scontributionishighlightedinthechart.

Shader.SetPass被选中,图表中高亮显示。

Inthehierarchicaltimedatatheselftimereferstotheamountoftimespentinaparticularfunctionnotincludingthetimespentcallingsub-functions.Inthescreenshotabove,forexample51.2%oftimeisspentintheCamera.Renderfunction.Thisfunctiondoesalotofworkandcallsthevariousdrawingandcullingfunctions.Excludingallthesefunctionsonly0.8%oftimeisspentactuallyintheCamera.Renderfunction.

在分层的时间数据的自我时间(selftime)指花费在特定函数的时间,不包括调用子函数所花费的时间。

在上面的截图,例如51.2%的时间花费在Camera.Render函数。

这个函数做了很多工作,并调用各种绘图和剔除的函数。

实际上排除了所有这些功能只有0.8%的时间花费在Camera.Render函数。

RenderingArea渲染区域

TheRenderingareadisplaysrenderingstatistics.TheNumberofDrawCalls,TrianglesandVerticesrenderedisdisplayedgraphicalinthetimeline.TheLowerpanedisplaysmorerenderingstatisticsandthesemorecloselymatchtheonesshownintheGameViewRenderingStatisticswindow.

渲染区域显示渲染统计数据。

DrawCalls,三角形和顶点渲染数量,在时间轴上显示以图形的方式。

下部窗格中显示更多渲染统计数据,这些数据与在游戏视图渲染统计数据窗口显示的数据相匹配。

MemoryArea内存区域

TheMemoryareadisplayssomememoryusagedata:

内存区域显示一些内存使用的数据:

∙TotalAllocatedisthetotalRAMusedbytheapplication.NotethatintheUnityEditorthisismemoryusedbyeverythingintheeditor;

gamebuildswillusemuchless.

总分配(TotalAllocated)是应用程序所使用的总内存。

请注意,在Unity编辑器,这是在编辑器中的一切使用的内存;

游戏构建后将使用少得多的内存。

∙TextureMemoryistheamountofvideomemoryusedbythetexturesinthecurrentframe.

纹理内存(TextureMemory

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2