Skip to content

Commit 7b874b9

Browse files
author
Unity Technologies
committed
com.unity.test-framework.performance@2.2.0-preview
## [2.2.0] - 2020-05-26 Add support for custom metadata ## [2.1.0] - 2020-05-14 Add flexible horizontal splitter for report window Fix date format
1 parent 70649ef commit 7b874b9

File tree

8 files changed

+61
-15
lines changed

8 files changed

+61
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [2.2.0] - 2020-05-26
4+
5+
Add support for custom metadata
6+
37
## [2.1.0] - 2020-05-14
48

59
Add flexible horizontal splitter for report window

Documentation~/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The Performance Testing Extension is intended to be used with, and complement, t
1111

1212
To install the Performance Testing Extension package
1313
1. Open the `manifest.json` file for your Unity project (located in the YourProject/Packages directory) in a text editor
14-
2. Add `"com.unity.test-framework.performance": "2.1.0-preview",` to the dependencies
14+
2. Add `"com.unity.test-framework.performance": "2.2.0-preview",` to the dependencies
1515
3. Save the manifest.json file
1616
4. Verify the Performance Testing Extension is now installed opening the Unity Package Manager window
1717

Runtime/PlayerCallbacks.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using System;
2+
#if USE_CUSTOM_METADATA
3+
using com.unity.test.metadatamanager;
4+
#endif
25
using Newtonsoft.Json;
36
using UnityEngine;
47
using UnityEngine.TestRunner;
@@ -15,6 +18,7 @@ namespace Unity.PerformanceTesting
1518
public class PlayerCallbacks : ITestRunCallback
1619
{
1720
internal static bool saved;
21+
1822
public void RunStarted(ITest testsToRun) { }
1923

2024
public void RunFinished(ITestResult testResults)
@@ -33,12 +37,25 @@ internal static void LogMetadata()
3337
run.Hardware = GetHardware();
3438
SetPlayerSettings(run);
3539
run.TestSuite = Application.isPlaying ? "Playmode" : "Editmode";
36-
40+
#if USE_CUSTOM_METADATA
41+
SetCustomMetadata(run);
42+
#endif
3743
var json = JsonConvert.SerializeObject(run);
3844
TestContext.Out?.WriteLine("##performancetestruninfo2:" + json);
3945
saved = true;
4046
}
4147

48+
#if USE_CUSTOM_METADATA
49+
private static void SetCustomMetadata(Run run)
50+
{
51+
var customMetadataManager = new CustomMetadataManager(run.Dependencies);
52+
// This field is historically not used so we can safely store additional string delimited
53+
// metadata here, then parse the metadata values out on the SQL side to give us access
54+
// to additional metadata that would normally require a schema change, or a property back field
55+
run.Player.AndroidTargetSdkVersion = customMetadataManager.GetCustomMetadata();
56+
}
57+
#endif
58+
4259
private static Run ReadPerformanceTestRun()
4360
{
4461
try

Runtime/PlayerCallbacks.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Unity.PerformanceTesting.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Unity.PerformanceTesting",
33
"references": [
4-
"UnityEngine.TestRunner"
4+
"UnityEngine.TestRunner",
5+
"com.unity.test.metadata-manager"
56
],
67
"includePlatforms": [],
78
"excludePlatforms": [],

Runtime/Unity.PerformanceTesting.asmdef.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/Editor/GenericTests.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
1+
using System;
12
using System.Collections;
23
using NUnit.Framework;
34
using Unity.PerformanceTesting;
5+
using Unity.PerformanceTesting.Runtime;
6+
using UnityEngine;
47
using UnityEngine.TestTools;
58

69
public class GenericTests
710
{
8-
[Performance]
11+
[Performance, Test]
12+
public void Utils_ConvertFromUnixTimestamp()
13+
{
14+
var date = new DateTime(2000, 1, 1, 1, 1, 1, 1, DateTimeKind.Utc);
15+
16+
var dt = Utils.ConvertFromUnixTimestamp(946688461001);
17+
18+
Assert.AreEqual(dt.Ticks, date.Ticks);
19+
}
20+
21+
[Performance, Test]
22+
public void Utils_ConvertToUnixTimestamp()
23+
{
24+
var dt = new DateTime(2000, 1, 1, 1, 1, 1, 1, DateTimeKind.Utc);
25+
DateTime.SpecifyKind(dt, DateTimeKind.Utc);
26+
27+
var stamp = Utils.ConvertToUnixTimestamp(dt);
28+
29+
Assert.AreEqual(stamp, 946688461001);
30+
}
31+
32+
[Performance, Test]
933
public void Default_VersionAttribute_IsSet()
1034
{
1135
Assert.AreEqual(PerformanceTest.Active.Version, "1");
1236
}
13-
14-
[Performance, Version("TEST")]
37+
38+
[Performance, Test, Version("TEST")]
1539
public void VersionAttribute_IsSet()
1640
{
1741
Assert.AreEqual(PerformanceTest.Active.Version, "TEST");
@@ -24,14 +48,14 @@ public void VersionAttribute_IsSet_OnTestCase(string name)
2448
Assert.AreEqual(PerformanceTest.Active.Version, "TEST");
2549
}
2650

27-
[Performance]
51+
[Performance, Test]
2852
public void ZeroSampleGroups_Highlighted_SingleSample()
2953
{
3054
var sg = new SampleGroup("TEST");
3155
Measure.Custom(sg, 0);
3256
}
3357

34-
[Performance]
58+
[Performance, Test]
3559
public void ZeroSampleGroups_Highlighted_MultipleSamples()
3660
{
3761
var sg = new SampleGroup("TEST");
@@ -57,7 +81,7 @@ public void Default_VersionAttribute_IsSet()
5781
{
5882
Assert.AreEqual(PerformanceTest.Active.Version, "1.1");
5983
}
60-
84+
6185
[Test, Performance, Version("TEST")]
6286
public void VersionAttribute_IsSet()
6387
{

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.unity.test-framework.performance",
33
"displayName": "Performance testing API",
4-
"version": "2.1.0-preview",
4+
"version": "2.2.0-preview",
55
"unity": "2019.3",
66
"unityRelease": "0a10",
77
"description": "Extension to the Unity Test framework package. Adds performance testing capabilities and collects configuration metadata.",
@@ -14,11 +14,11 @@
1414
"com.unity.nuget.newtonsoft-json": "2.0.0-preview"
1515
},
1616
"upmCi": {
17-
"footprint": "bffa451d2d70421572fe14efb2acbaa69f80eeff"
17+
"footprint": "acdb45aa0381a84a127b5bc4b1aecb5abcc7b142"
1818
},
1919
"repository": {
20-
"type": "git",
2120
"url": "https://github.cds.internal.unity3d.com/unity/com.unity.test-framework.performance.git",
22-
"revision": "4fcf08c79385aef3efa6862e69754565792ef757"
21+
"type": "git",
22+
"revision": "1d0ef47bac7a18f1c14da1ee42082ae030273971"
2323
}
2424
}

0 commit comments

Comments
 (0)