创建器材-性能分析框架-说明文档
<p>[TOC]</p>
<table>
<thead>
<tr>
<th>作者</th>
<th>QFord(350107)</th>
</tr>
</thead>
<tbody>
<tr>
<td>创建日期</td>
<td>2023-2-5</td>
</tr>
<tr>
<td>最后更新日期</td>
<td>2023-2-16</td>
</tr>
<tr>
<td>更新</td>
<td>ljx(优化了报表格式并新增了项目)</td>
</tr>
</tbody>
</table>
<p><center><font size = 6><strong>创建器材-性能分析框架-说明文档</strong></font></center></p>
<h1>需求背景</h1>
<p>对于<strong>物件播放组件</strong>来说,[创建器材]的耗时是非常重要的性能指标。
因此,我们需要一个工具来测试和记录这个数据,以便我们明确哪些模块/组件是需要优化的。</p>
<h1>原始需求</h1>
<ul>
<li>可以记录每次[创建器材]的耗时</li>
<li>QA可以一次性创建(通过UI面板输入或接口)多个器材</li>
<li>提供创建的器材的面数统计的功能</li>
<li>性能数据(当前时间、器材code,创建耗时)可以输出到文件,比如csv格式,便于通过Excel查看和分析。</li>
<li>其他数据,器材的面数</li>
</ul>
<h1>方案设计</h1>
<ul>
<li>利用诊断工具类 Stopwatch ,封装一个用来获取函数执行耗时的方法。</li>
<li>汇总 执行耗时等诊断数据。</li>
<li>器材面数统计比较消耗,提供开关,以免干扰器材创建准确性。</li>
<li>提供一个独立测试场景,便于QA输入测试器材列表信息,通过按钮输出测试数据文件。</li>
</ul>
<h1>技术要点</h1>
<p><strong>核心算法</strong>:</p>
<pre><code class="language-csharp">System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
// 创建器材的代码
stopwatch.Stop();
long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;//耗时(单位:毫秒)</code></pre>
<h1>使用说明</h1>
<p>详见测试场景 <strong>CreateElementsNFR_Test</strong>
核心代码 TestUtil.cs</p>