Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

43 行
1.3 KiB

using NUnit.Framework;
using UnityEditor.Graphs;
using UnityEngine;
namespace MLAgents.Tests
{
public class TimerTests
{
[Test]
public void TestNested()
{
TimerStack myTimer = TimerStack.Instance;
myTimer.Reset();
using (myTimer.Scoped("foo"))
{
for (int i = 0; i < 5; i++)
{
using (myTimer.Scoped("bar"))
{
myTimer.SetGauge("my_gauge", (float)i);
}
}
}
var rootChildren = myTimer.RootNode.Children;
Assert.That(rootChildren, Contains.Key("foo"));
Assert.AreEqual(rootChildren["foo"].NumCalls, 1);
var gauge = myTimer.RootNode.Gauges["my_gauge"];
Assert.NotNull(gauge);
Assert.AreEqual(5, gauge.count);
Assert.AreEqual(0, gauge.minValue);
Assert.AreEqual(4, gauge.maxValue);
Assert.AreEqual(4, gauge.value);
var fooChildren = rootChildren["foo"].Children;
Assert.That(fooChildren, Contains.Key("bar"));
Assert.AreEqual(fooChildren["bar"].NumCalls, 5);
myTimer.Reset();
Assert.AreEqual(myTimer.RootNode.Children, null);
}
}
}