public PerformanceLog(string description, LogType logType) { this.description = description; this.logType = logType; this.startTime = HighPrecisionTimer.Now; this.parent = current; current = this; if (parent != null) { this.level = parent.level + 1; if (IsVerbose || logType != LogType.Verbose) { parent.childs.Add(this); } } else { this.level = 0; } }
void Display() { GlobalSettings.RunningTime = DateTime.Now - startTime; using(PerformanceLog log = new PerformanceLog("Frame " + (framesRendered++))) { using(new PerformanceLog("Clear")) { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); } Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); using(new PerformanceLog("Render")) { collada.Render(); } using(new PerformanceLog("Swap")) { Glut.glutSwapBuffers(); } log.Stop(); Glut.glutSetWindowTitle(String.Format("Collada Viewer - {0:f1} FPS", 1 / log.Duration.TotalSeconds)); } }
static PerformanceLog() { current = null; Root = new PerformanceLog("Root"); current = Root; }
public void Stop() { endTime = HighPrecisionTimer.Now; current = parent; PrintOnConsole(); }