Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GenerateShaderPerformance.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 GenerateShaderPerformance
9  {
10  private static Stopwatch Global = new Stopwatch();
11  private static Stopwatch GroupByConstantBuffer = new Stopwatch();
12  private static Stopwatch StreamCreator = new Stopwatch();
13  private static Stopwatch ExpandForEachStatements = new Stopwatch();
14  private static Stopwatch RemoveUselessVariables = new Stopwatch();
15 
16  public static void Start(GenerateShaderStage stage)
17  {
18  switch (stage)
19  {
20  case GenerateShaderStage.Global:
21  Global.Start();
22  break;
23  case GenerateShaderStage.GroupByConstantBuffer:
24  GroupByConstantBuffer.Start();
25  break;
26  case GenerateShaderStage.StreamCreator:
27  StreamCreator.Start();
28  break;
29  case GenerateShaderStage.ExpandForEachStatements:
30  ExpandForEachStatements.Start();
31  break;
32  case GenerateShaderStage.RemoveUselessVariables:
33  RemoveUselessVariables.Start();
34  break;
35  }
36  }
37 
38  public static void Pause(GenerateShaderStage stage)
39  {
40  switch (stage)
41  {
42  case GenerateShaderStage.Global:
43  Global.Stop();
44  break;
45  case GenerateShaderStage.GroupByConstantBuffer:
46  GroupByConstantBuffer.Stop();
47  break;
48  case GenerateShaderStage.StreamCreator:
49  StreamCreator.Stop();
50  break;
51  case GenerateShaderStage.ExpandForEachStatements:
52  ExpandForEachStatements.Stop();
53  break;
54  case GenerateShaderStage.RemoveUselessVariables:
55  RemoveUselessVariables.Start();
56  break;
57  }
58  }
59 
60  public static void Reset()
61  {
62  Global.Reset();
63  GroupByConstantBuffer.Reset();
64  StreamCreator.Reset();
65  ExpandForEachStatements.Reset();
66  RemoveUselessVariables.Reset();
67  }
68 
69  public static void PrintResult()
70  {
71  Console.WriteLine();
72  Console.WriteLine(@"----------------------------GENERATE SHADER ANALYZER-----------------------------");
73  Console.WriteLine(@"Whole generation took {0} ms", Global.ElapsedMilliseconds);
74  Console.WriteLine(@"GroupByConstantBuffer took {0} ms", GroupByConstantBuffer.ElapsedMilliseconds);
75  Console.WriteLine(@"StreamCreator took {0} ms", StreamCreator.ElapsedMilliseconds);
76  Console.WriteLine(@"ExpandForEachStatements took {0} ms", ExpandForEachStatements.ElapsedMilliseconds);
77  Console.WriteLine(@"RemoveUselessVariables took {0} ms", RemoveUselessVariables.ElapsedMilliseconds);
78  Console.WriteLine(@"-------------------------------------------------------------------------------");
79  Console.WriteLine();
80  }
81  }
82 
83  public enum GenerateShaderStage
84  {
85  Global,
90  }
91 }