File: vtkRenderTimings.h

package info (click to toggle)
vtk7 7.1.1%2Bdfsg2-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 127,396 kB
  • sloc: cpp: 1,539,584; ansic: 124,382; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 126; objc: 83
file content (189 lines) | stat: -rw-r--r-- 5,420 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    VTKRenderTimings.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#ifndef vtkRenderTimings_h
#define vtkRenderTimings_h

/**
 * Define the classes we use for running timing benchmarks
 */

#include "vtkTimerLog.h"
#include <vtksys/SystemInformation.hxx>
#include <vtksys/RegularExpression.hxx>
#include <vtksys/CommandLineArguments.hxx>
#include <map>

class vtkRTTestResult;
class vtkRTTestSequence;
class vtkRenderTimings;

class vtkRTTest
{
public:
  // what is the name of this test
  std::string GetName() { return this->Name; }

  // when reporting a summary result use this key to
  // determine the amount of triangles rendered
  virtual const char *GetSecondSummaryResultName() = 0;

  // when reporting a summary result this is the
  // field that should be reported.
  virtual const char *GetSummaryResultName() = 0;

  // when reporting a summary result should we use the
  // largest value or smallest?
  virtual bool UseLargestSummaryResult() { return true; }

  // Set/Get the time allowed for this test
  // Tests should check if they are going more than 50%
  // beyond this number they should short circuit if
  // they can gracefully.
  virtual void SetTargetTime(float tt) { this->TargetTime = tt; }
  virtual float GetTargetTime() { return this->TargetTime; }

  void SetRenderSize(int width, int height) { this->RenderWidth = width; this->RenderHeight = height; }
  int GetRenderWidth() { return this->RenderWidth; }
  int GetRenderHeight() { return this->RenderHeight; }

  // run the test, argc and argv are extra arguments that the test might
  // use.
  virtual vtkRTTestResult Run(vtkRTTestSequence *ats, int argc, char *argv[]) = 0;

  vtkRTTest(const char *name)
  {
    this->TargetTime = 1.0;
    this->Name = name;
    RenderWidth = RenderHeight = 600;
  }

  virtual ~vtkRTTest() {}

protected:
  float TargetTime;
  std::string Name;
  int RenderWidth, RenderHeight;
};

class vtkRTTestResult
{
public:
  std::map<std::string,double> Results;
  int SequenceNumber;
  void ReportResults(vtkRTTest *test, ostream &ost)
  {
    ost << test->GetName();
    std::map<std::string, double>::iterator rItr;
    for (rItr = this->Results.begin(); rItr != this->Results.end(); rItr++)
      {
      ost << ", " << rItr->first << ", " << rItr->second;
      }
    ost << "\n";
  }
};

class vtkRTTestSequence
{
public:
  virtual void Run();
  virtual void ReportSummaryResults(ostream &ost);
  virtual void ReportDetailedResults(ostream &ost);

  // tests should use these functions to determine what resolution
  // to use in scaling their test. The functions will always return
  // numbers then when multiplied will result in 1, 2, 3, or 5
  // times 10 to some power. These functions use the SequenceCount
  // to determine what number to return. When the dimensions
  // are not equal, we guarantee that the larger dimensions
  // come first
  void GetSequenceNumbers(int &xdim);
  void GetSequenceNumbers(int &xdim, int &ydim);
  void GetSequenceNumbers(int &xdim, int &ydim, int &zdim);
  void GetSequenceNumbers(int &xdim, int &ydim, int &zdim, int &wdim);

  // display the results in realtime using VTK charting
  void SetChartResults(bool v) { this->ChartResults = v; }

  vtkRTTest *Test;
  float TargetTime;

  vtkRTTestSequence(vtkRenderTimings *rt)
    {
    this->Test = NULL;
    this->TargetTime = 10.0;
    this->RenderTimings = rt;
    this->ChartResults = true;
    }

virtual ~vtkRTTestSequence() {}

protected:
  std::vector<vtkRTTestResult> TestResults;
  int SequenceCount;
  vtkRenderTimings *RenderTimings;
  bool ChartResults;
};

// a class to run a bunch of timing tests and
// report the results
class vtkRenderTimings
{
public:
  vtkRenderTimings();

  // get the sequence start and end values
  int GetSequenceStart() { return this->SequenceStart; }
  int GetSequenceEnd() { return this->SequenceEnd; }

  // get the maxmimum time allowed per step
  double GetSequenceStepTimeLimit() { return this->SequenceStepTimeLimit; }

  // get the render size
  int GetRenderWidth() { return this->RenderWidth; }
  int GetRenderHeight() { return this->RenderHeight; }

  // parse and act on the command line arguments
  int ParseCommandLineArguments(int argc, char *argv[]);

  // get the arguments
  vtksys::CommandLineArguments &GetArguments() { return this->Arguments; }

  std::string GetSystemName() { return this->SystemName; }

  std::vector<vtkRTTest *> TestsToRun;
  std::vector<vtkRTTestSequence *> TestSequences;

protected:
  int RunTests();
  void ReportResults();

private:
  std::string Regex; // regualr expression for tests
  double TargetTime;
  std::string SystemName;
  vtksys::CommandLineArguments Arguments;
  bool DisplayHelp;
  bool ListTests;
  bool NoChartResults;
  int SequenceStart;
  int SequenceEnd;
  double SequenceStepTimeLimit;
  std::string DetailedResultsFileName;
  int RenderWidth;
  int RenderHeight;
};

#endif