@@ -12,7 +12,7 @@ namespace UnityPerformanceBenchmarkReporter
1212{
1313 public class TestResultJsonParser : IParser
1414 {
15- public PerformanceTestRun Parse ( string path )
15+ public PerformanceTestRun Parse ( string path , int version )
1616 {
1717 string report = "" ;
1818 try
@@ -34,13 +34,22 @@ public PerformanceTestRun Parse(string path)
3434 throw ;
3535 }
3636
37- return ParseJson ( report ) ;
37+ switch ( version )
38+ {
39+ case 1 :
40+ return ParseJsonV1 ( report ) ;
41+ case 2 :
42+ return ParseJsonV2 ( report ) ;
43+ default :
44+ return null ;
45+ }
3846 }
3947
40- private static PerformanceTestRun ParseJson ( string json )
48+ private static PerformanceTestRun ParseJsonV1 ( string json )
4149 {
4250
4351 PerformanceTestRun result ;
52+
4453 try
4554 {
4655 result = JsonConvert . DeserializeObject < PerformanceTestRun > ( json ) ;
@@ -55,6 +64,117 @@ private static PerformanceTestRun ParseJson(string json)
5564 return result ;
5665 }
5766
67+ private static PerformanceTestRun ParseJsonV2 ( string json )
68+ {
69+
70+ Run run = null ;
71+ try
72+ {
73+ run = JsonConvert . DeserializeObject < Run > ( json ) ;
74+ }
75+ catch ( System . Exception )
76+ {
77+ throw ;
78+ }
79+
80+ if ( run != null )
81+ {
82+ var testRun = new PerformanceTestRun ( )
83+ {
84+ BuildSettings = new BuildSettings ( )
85+ {
86+ Platform = run . Player . Platform ,
87+ BuildTarget = run . Player . BuildTarget ,
88+ DevelopmentPlayer = true ,
89+ AndroidBuildSystem = run . Player . AndroidBuildSystem
90+ } ,
91+ EditorVersion = new EditorVersion ( )
92+ {
93+ Branch = run . Editor . Branch ,
94+ DateSeconds = run . Editor . Date ,
95+ FullVersion = $ "{ run . Editor . Version } ({ run . Editor . Changeset } )",
96+ RevisionValue = 0
97+ } ,
98+ PlayerSettings = new PlayerSettings ( )
99+ {
100+ GpuSkinning = run . Player . GpuSkinning ,
101+ GraphicsApi = run . Player . GraphicsApi ,
102+ RenderThreadingMode = run . Player . RenderThreadingMode ,
103+ ScriptingBackend = run . Player . ScriptingBackend ,
104+ AndroidTargetSdkVersion = run . Player . AndroidTargetSdkVersion ,
105+ EnabledXrTargets = new List < string > ( ) ,
106+ ScriptingRuntimeVersion = "" ,
107+ StereoRenderingPath = run . Player . StereoRenderingPath
108+ } ,
109+ QualitySettings = new QualitySettings ( )
110+ {
111+ Vsync = run . Player . Vsync ,
112+ AntiAliasing = run . Player . AntiAliasing ,
113+ AnisotropicFiltering = run . Player . AnisotropicFiltering ,
114+ BlendWeights = run . Player . BlendWeights ,
115+ ColorSpace = run . Player . ColorSpace
116+ } ,
117+ ScreenSettings = new ScreenSettings ( )
118+ {
119+ Fullscreen = run . Player . Fullscreen ,
120+ ScreenHeight = run . Player . ScreenHeight ,
121+ ScreenWidth = run . Player . ScreenWidth ,
122+ ScreenRefreshRate = run . Player . ScreenRefreshRate
123+ } ,
124+ PlayerSystemInfo = new Entities . PlayerSystemInfo ( )
125+ {
126+ DeviceModel = run . Hardware . DeviceModel ,
127+ DeviceName = run . Hardware . DeviceName ,
128+ OperatingSystem = run . Hardware . OperatingSystem ,
129+ ProcessorCount = run . Hardware . ProcessorCount ,
130+ ProcessorType = run . Hardware . ProcessorType ,
131+ GraphicsDeviceName = run . Hardware . GraphicsDeviceName ,
132+ SystemMemorySize = run . Hardware . SystemMemorySizeMB ,
133+ XrDevice = run . Hardware . XrDevice ,
134+ XrModel = run . Hardware . XrModel
135+ } ,
136+ StartTime = run . Date ,
137+ TestSuite = run . TestSuite ,
138+ Results = new List < PerformanceTestResult > ( )
139+ } ;
140+
141+ testRun . EndTime = DateTime . Now . ToUniversalTime ( )
142+ . Subtract ( new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) )
143+ . TotalMilliseconds ;
144+
145+ foreach ( var res in run . Results )
146+ {
147+ var pt = new PerformanceTestResult ( )
148+ {
149+ TestCategories = res . Categories ,
150+ TestName = res . Name ,
151+ TestVersion = res . Version ,
152+ SampleGroups = res . SampleGroups . Select ( sg => new Entities . SampleGroup
153+ {
154+ Samples = sg . Samples ,
155+ Average = sg . Average ,
156+ Max = sg . Max ,
157+ Median = sg . Median ,
158+ Min = sg . Min ,
159+ Sum = sg . Sum ,
160+ StandardDeviation = sg . StandardDeviation ,
161+ SampleCount = sg . Samples . Count ,
162+ Definition = new SampleGroupDefinition ( )
163+ {
164+ Name = sg . Name ,
165+ SampleUnit = ( Entities . SampleUnit ) sg . Unit ,
166+ IncreaseIsBetter = sg . IncreaseIsBetter
167+ }
168+ } ) . ToList ( )
169+ } ;
170+ testRun . Results . Add ( pt ) ;
171+ }
172+
173+ return testRun ;
174+ }
175+
176+ return null ;
177+ }
58178
59179 }
60180}
0 commit comments