Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MixPerformance.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Diagnostics;
5 
6 namespace SiliconStudio.Paradox.Shaders.Parser.Performance
7 {
8  public static class MixPerformance
9  {
10  private static Stopwatch Global = new Stopwatch();
11  private static Stopwatch AddDefaultCompositions = new Stopwatch();
12  private static Stopwatch CreateReferencesStructures = new Stopwatch();
13  private static Stopwatch RegenKeys = new Stopwatch();
14  private static Stopwatch BuildMixinInheritance = new Stopwatch();
15  private static Stopwatch ComputeMixinOccurence = new Stopwatch();
16  private static Stopwatch BuildStageInheritance = new Stopwatch();
17  private static Stopwatch LinkVariables = new Stopwatch();
18  private static Stopwatch ProcessExterns = new Stopwatch();
19  private static Stopwatch PatchAllMethodInferences = new Stopwatch();
20  private static Stopwatch MergeReferences = new Stopwatch();
21  private static Stopwatch RenameAllVariables = new Stopwatch();
22  private static Stopwatch RenameAllMethods = new Stopwatch();
23  private static Stopwatch GenerateShader = new Stopwatch();
24 
25  public static void Start(MixStage stage)
26  {
27  switch (stage)
28  {
29  case MixStage.Global:
30  Global.Start();
31  break;
32  case MixStage.AddDefaultCompositions:
33  AddDefaultCompositions.Start();
34  break;
35  case MixStage.CreateReferencesStructures:
36  CreateReferencesStructures.Start();
37  break;
38  case MixStage.RegenKeys:
39  RegenKeys.Start();
40  break;
41  case MixStage.BuildMixinInheritance:
42  BuildMixinInheritance.Start();
43  break;
44  case MixStage.ComputeMixinOccurence:
45  ComputeMixinOccurence.Start();
46  break;
47  case MixStage.BuildStageInheritance:
48  BuildStageInheritance.Start();
49  break;
50  case MixStage.LinkVariables:
51  LinkVariables.Start();
52  break;
53  case MixStage.ProcessExterns:
54  ProcessExterns.Start();
55  break;
56  case MixStage.PatchAllMethodInferences:
57  PatchAllMethodInferences.Start();
58  break;
59  case MixStage.MergeReferences:
60  MergeReferences.Start();
61  break;
62  case MixStage.RenameAllVariables:
63  RenameAllVariables.Start();
64  break;
65  case MixStage.RenameAllMethods:
66  RenameAllMethods.Start();
67  break;
68  case MixStage.GenerateShader:
69  GenerateShader.Start();
70  break;
71  }
72  }
73 
74  public static void Pause(MixStage stage)
75  {
76  switch (stage)
77  {
78  case MixStage.Global:
79  Global.Stop();
80  break;
81  case MixStage.AddDefaultCompositions:
82  AddDefaultCompositions.Stop();
83  break;
84  case MixStage.CreateReferencesStructures:
85  CreateReferencesStructures.Stop();
86  break;
87  case MixStage.RegenKeys:
88  RegenKeys.Stop();
89  break;
90  case MixStage.BuildMixinInheritance:
91  BuildMixinInheritance.Stop();
92  break;
93  case MixStage.ComputeMixinOccurence:
94  ComputeMixinOccurence.Stop();
95  break;
96  case MixStage.BuildStageInheritance:
97  BuildStageInheritance.Stop();
98  break;
99  case MixStage.LinkVariables:
100  LinkVariables.Stop();
101  break;
102  case MixStage.ProcessExterns:
103  ProcessExterns.Stop();
104  break;
105  case MixStage.PatchAllMethodInferences:
106  PatchAllMethodInferences.Stop();
107  break;
108  case MixStage.MergeReferences:
109  MergeReferences.Stop();
110  break;
111  case MixStage.RenameAllVariables:
112  RenameAllVariables.Stop();
113  break;
114  case MixStage.RenameAllMethods:
115  RenameAllMethods.Stop();
116  break;
117  case MixStage.GenerateShader:
118  GenerateShader.Stop();
119  break;
120  }
121  }
122 
123  public static void Reset()
124  {
125  Global.Reset();
126  AddDefaultCompositions.Reset();
127  CreateReferencesStructures.Reset();
128  RegenKeys.Reset();
129  BuildMixinInheritance.Reset();
130  ComputeMixinOccurence.Reset();
131  BuildStageInheritance.Reset();
132  LinkVariables.Reset();
133  ProcessExterns.Reset();
134  PatchAllMethodInferences.Reset();
135  MergeReferences.Reset();
136  RenameAllVariables.Reset();
137  RenameAllMethods.Reset();
138  GenerateShader.Reset();
139  }
140 
141  public static void PrintResult()
142  {
143  Console.WriteLine();
144  Console.WriteLine(@"---------------------------------MIX ANALYZER-----------------------------------");
145  Console.WriteLine(@"Whole mix took {0} ms", Global.ElapsedMilliseconds);
146  Console.WriteLine(@"AddDefaultCompositions took {0} ms", AddDefaultCompositions.ElapsedMilliseconds);
147  Console.WriteLine(@"CreateReferencesStructures took {0} ms", CreateReferencesStructures.ElapsedMilliseconds);
148  Console.WriteLine(@"RegenKeys took {0} ms", RegenKeys.ElapsedMilliseconds);
149  Console.WriteLine(@"BuildMixinInheritance took {0} ms", BuildMixinInheritance.ElapsedMilliseconds);
150  Console.WriteLine(@"ComputeMixinOccurence took {0} ms", ComputeMixinOccurence.ElapsedMilliseconds);
151  Console.WriteLine(@"BuildStageInheritance took {0} ms", BuildStageInheritance.ElapsedMilliseconds);
152  Console.WriteLine(@"LinkVariables took {0} ms", LinkVariables.ElapsedMilliseconds);
153  Console.WriteLine(@"ProcessExterns took {0} ms", ProcessExterns.ElapsedMilliseconds);
154  Console.WriteLine(@"PatchAllMethodInferences took {0} ms", PatchAllMethodInferences.ElapsedMilliseconds);
155  Console.WriteLine(@"MergeReferences took {0} ms", MergeReferences.ElapsedMilliseconds);
156  Console.WriteLine(@"RenameAllVariables took {0} ms", RenameAllVariables.ElapsedMilliseconds);
157  Console.WriteLine(@"RenameAllMethods took {0} ms", RenameAllMethods.ElapsedMilliseconds);
158  Console.WriteLine(@"GenerateShader took {0} ms", GenerateShader.ElapsedMilliseconds);
159  Console.WriteLine(@"-------------------------------------------------------------------------------");
160  Console.WriteLine();
161  }
162  }
163 
164  public enum MixStage
165  {
166  Global,
169  RegenKeys,
180  }
181 }