7
7
using System . Text ;
8
8
using System . Text . RegularExpressions ;
9
9
using UnityPerformanceBenchmarkReporter . Entities ;
10
+ using System . Runtime . InteropServices ;
10
11
11
12
namespace UnityPerformanceBenchmarkReporter . Report
12
13
{
@@ -20,7 +21,8 @@ public class ReportWriter
20
21
"styles.css" ,
21
22
"UnityLogo.png" ,
22
23
"warning.png" ,
23
- "help.png"
24
+ "help.png" ,
25
+ "help-hover.png"
24
26
} ;
25
27
26
28
private readonly Dictionary < string , string [ ] > excludedConfigFieldNames = new Dictionary < string , string [ ] > ( ) ;
@@ -32,6 +34,8 @@ public class ReportWriter
32
34
private uint thisSigFig ;
33
35
private bool thisHasBenchmarkResults ;
34
36
private MetadataValidator metadataValidator ;
37
+ private bool vrSupported = false ;
38
+ private char pathSeperator = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? '\\ ' : '/' ;
35
39
36
40
public ReportWriter ( Dictionary < string , string [ ] > excludedTestConfigs = null )
37
41
{
@@ -99,7 +103,8 @@ private static FileStream TryCreateHtmlFile(string htmlFileName)
99
103
100
104
private void WriteEmbeddedResourceFiles ( DirectoryInfo benchmarkDirectory )
101
105
{
102
- var assemblyNameParts = Assembly . GetExecutingAssembly ( ) . Location . Split ( '\\ ' ) ;
106
+ var assemblyNameParts = Assembly . GetExecutingAssembly ( ) . Location . Split ( pathSeperator ) ;
107
+
103
108
var assemblyName = assemblyNameParts [ assemblyNameParts . Length - 1 ] . Split ( '.' ) [ 0 ] ;
104
109
105
110
foreach ( var embeddedResourceName in embeddedResourceNames )
@@ -466,6 +471,7 @@ private void WriteToggleCanvasWithNoFailures(StreamWriter rw)
466
471
private void WriteHeader ( StreamWriter rw )
467
472
{
468
473
rw . WriteLine ( "<head>" ) ;
474
+ rw . WriteLine ( "<meta charset=\" utf-8\" />" ) ;
469
475
rw . WriteLine ( "<title>Unity Performance Benchmark Report</title>" ) ;
470
476
rw . WriteLine ( "<script src=\" Chart.bundle.js\" ></script>" ) ;
471
477
rw . WriteLine ( "<link rel=\" stylesheet\" href=\" styles.css\" >" ) ;
@@ -726,9 +732,15 @@ private void WriteClassNameWithFields<T>(StreamWriter rw, object instance, strin
726
732
727
733
var sb = new StringBuilder ( ) ;
728
734
729
- foreach ( var field in thisObject . GetType ( ) . GetFields ( ) )
735
+ if ( thisObject . GetType ( ) . GetFields ( ) . Any ( f => f . Name . Equals ( "VrSupported" ) ) )
730
736
{
737
+ vrSupported = ( bool ) thisObject . GetType ( ) . GetFields ( ) . First ( f => f . Name . Equals ( "VrSupported" ) ) . GetValue ( thisObject ) ;
738
+ }
739
+
740
+
731
741
742
+ foreach ( var field in thisObject . GetType ( ) . GetFields ( ) )
743
+ {
732
744
if ( excludedFieldNames != null && excludedFieldNames . Contains ( field . Name ) )
733
745
{
734
746
continue ;
@@ -758,8 +770,8 @@ private void WriteClassNameWithFields<T>(StreamWriter rw, object instance, strin
758
770
? mismatchedValue . First ( kv => kv . Key . Equals ( resultFile ) ) . Value
759
771
: baselineValue ;
760
772
761
- var pathParts = resultFile . Split ( ' \\ ' ) ;
762
- var path = string . Join ( ' \\ ' , pathParts . Take ( pathParts . Length - 1 ) ) ;
773
+ var pathParts = resultFile . Split ( pathSeperator ) ;
774
+ var path = string . Join ( pathSeperator , pathParts . Take ( pathParts . Length - 1 ) ) ;
763
775
764
776
765
777
sb . Append ( string . Format (
@@ -812,26 +824,42 @@ private static bool TypeHasValidMismatches<T>(Dictionary<string, Dictionary<stri
812
824
813
825
private object GetFieldValues < T > ( FieldInfo field , T thisObject )
814
826
{
815
- return IsIEnumerableFieldType ( field ) ? ConvertIEnumberableToString ( field , thisObject ) : field . GetValue ( thisObject ) ;
827
+ return IsIEnumerableFieldType ( field ) ? ConvertIEnumberableToString ( field , thisObject ) : GetValue ( field , thisObject ) ;
828
+ }
829
+
830
+ private object GetValue < T > ( FieldInfo field , T thisObject )
831
+ {
832
+ return
833
+ ( field . Name . Equals ( "StereoRenderingPath" ) || field . Name . Equals ( "XrModel" ) || field . Name . Equals ( "XrDevice" ) ) && ! vrSupported ?
834
+ "None" :
835
+ field . GetValue ( thisObject ) ;
816
836
}
817
837
818
- private static bool IsIEnumerableFieldType ( FieldInfo field )
838
+ private bool IsIEnumerableFieldType ( FieldInfo field )
819
839
{
820
840
return typeof ( IEnumerable ) . IsAssignableFrom ( field . FieldType ) && field . FieldType != typeof ( string ) ;
821
841
}
822
842
823
843
private string ConvertIEnumberableToString < T > ( FieldInfo field , T thisObject )
824
844
{
825
845
var sb = new StringBuilder ( ) ;
826
- foreach ( var enumerable in ( IEnumerable ) field . GetValue ( thisObject ) )
846
+ var fieldValues = ( ( IEnumerable ) field . GetValue ( thisObject ) ) as List < string > ;
847
+ if ( fieldValues != null && fieldValues . Any ( ) )
827
848
{
828
- sb . Append ( enumerable + "," ) ;
829
- }
849
+ foreach ( var enumerable in fieldValues )
850
+ {
851
+ sb . Append ( enumerable + "," ) ;
852
+ }
830
853
831
- if ( sb . ToString ( ) . EndsWith ( ',' ) )
854
+ if ( sb . ToString ( ) . EndsWith ( ',' ) )
855
+ {
856
+ // trim trailing comma
857
+ sb . Length -- ;
858
+ }
859
+ }
860
+ else
832
861
{
833
- // trim trailing comma
834
- sb . Length -- ;
862
+ sb . Append ( "None" ) ;
835
863
}
836
864
837
865
return sb . ToString ( ) ;
0 commit comments