1616using UnityEditor ;
1717#endif
1818
19+ /// <summary>
20+ /// The existence of this PlaymodeMetdataCollector class in the PerformanceBenchmark tests is a hack to
21+ /// enable collection of test metadata when IL2CPP scriptingbackend is enabled. This same script is used in the
22+ /// performance testing extension and works fine when mono scriptingbackend is used. However, not so much for IL2CPP
23+ /// is used. This issue (most likely a JSON deserialization/stripping issue) is being investigated, but for now,
24+ /// if you want to ensure test run metadata is included in the result when using IL2CPP, include this class/test in your project.
25+ /// </summary>
1926[ Category ( "Performance" ) ]
2027public class PlaymodeMetadataCollector : IPrebuildSetup
2128{
@@ -36,6 +43,62 @@ public IEnumerator GetPlayerSettingsTest()
3643 m_TestRun . TestSuite = "Playmode" ;
3744 m_TestRun . BuildSettings . Platform = Application . platform . ToString ( ) ;
3845
46+ // Begin hack within hack
47+ // It seem we're losing metadata potentially from deserialization.
48+ // This hack seems to workaround the issue, resulting in more consistent
49+ // metadata
50+ using ( StreamWriter sw = new StreamWriter ( Stream . Null ) )
51+ {
52+ // PlayerSystemInfo
53+ sw . Write ( m_TestRun . PlayerSystemInfo . DeviceModel ) ;
54+ sw . Write ( m_TestRun . PlayerSystemInfo . DeviceName ) ;
55+ sw . Write ( m_TestRun . PlayerSystemInfo . GraphicsDeviceName ) ;
56+ sw . Write ( m_TestRun . PlayerSystemInfo . OperatingSystem ) ;
57+ sw . Write ( m_TestRun . PlayerSystemInfo . ProcessorCount ) ;
58+ sw . Write ( m_TestRun . PlayerSystemInfo . SystemMemorySize ) ;
59+ sw . Write ( m_TestRun . PlayerSystemInfo . XrDevice ) ;
60+ sw . Write ( m_TestRun . PlayerSystemInfo . XrModel ) ;
61+
62+ //PlayerSettings
63+ sw . Write ( m_TestRun . PlayerSettings . AndroidMinimumSdkVersion ) ;
64+ sw . Write ( m_TestRun . PlayerSettings . AndroidTargetSdkVersion ) ;
65+ sw . Write ( m_TestRun . PlayerSettings . Batchmode ) ;
66+ sw . Write ( m_TestRun . PlayerSettings . EnabledXrTargets ) ;
67+ sw . Write ( m_TestRun . PlayerSettings . GpuSkinning ) ;
68+ sw . Write ( m_TestRun . PlayerSettings . GraphicsApi ) ;
69+ sw . Write ( m_TestRun . PlayerSettings . GraphicsJobs ) ;
70+ sw . Write ( m_TestRun . PlayerSettings . MtRendering ) ;
71+ sw . Write ( m_TestRun . PlayerSettings . RenderThreadingMode ) ;
72+ sw . Write ( m_TestRun . PlayerSettings . ScriptingBackend ) ;
73+ sw . Write ( m_TestRun . PlayerSettings . ScriptingRuntimeVersion ) ;
74+ sw . Write ( m_TestRun . PlayerSettings . StereoRenderingPath ) ;
75+ sw . Write ( m_TestRun . PlayerSettings . VrSupported ) ;
76+
77+ //QualitySettings
78+ sw . Write ( m_TestRun . QualitySettings . AnisotropicFiltering ) ;
79+ sw . Write ( m_TestRun . QualitySettings . AntiAliasing ) ;
80+ sw . Write ( m_TestRun . QualitySettings . BlendWeights ) ;
81+ sw . Write ( m_TestRun . QualitySettings . ColorSpace ) ;
82+ sw . Write ( m_TestRun . QualitySettings . Vsync ) ;
83+
84+ //ScreenSettings
85+ sw . Write ( m_TestRun . ScreenSettings . Fullscreen ) ;
86+ sw . Write ( m_TestRun . ScreenSettings . ScreenHeight ) ;
87+ sw . Write ( m_TestRun . ScreenSettings . ScreenRefreshRate ) ;
88+ sw . Write ( m_TestRun . ScreenSettings . ScreenWidth ) ;
89+
90+ //BuildSettings
91+ sw . Write ( m_TestRun . BuildSettings . AndroidBuildSystem ) ;
92+ sw . Write ( m_TestRun . BuildSettings . BuildTarget ) ;
93+ sw . Write ( m_TestRun . BuildSettings . DevelopmentPlayer ) ;
94+ sw . Write ( m_TestRun . BuildSettings . Platform ) ;
95+
96+ //EditorSettings
97+ sw . Write ( m_TestRun . EditorVersion . RevisionValue ) ;
98+ sw . Write ( m_TestRun . EditorVersion . FullVersion ) ;
99+ }
100+ // End hack
101+
39102 TestContext . Out . Write ( "##performancetestruninfo:" + JsonUtility . ToJson ( m_TestRun ) ) ;
40103 }
41104
0 commit comments