Source

GL Profile Suite / tests / util / report.h

Full commit

#ifndef PERFORMANCE_REPORT_H
#define PERFORMANCE_REPORT_H

#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
#include <vector>
#include <boost/range.hpp>
#include <boost/range/any_range.hpp>
#include <iosfwd>

namespace util
{
	struct ParamDecl
	{
		const char *name;
	};

	struct TestDesc
	{
		const char *name;
		const char *description;
	};

	struct ReportData;
	struct TestDatumElement;

	//Data structure for storing recorded data and formatting it for output.
	class Report : public boost::noncopyable
	{
	public:
		Report(int numExecutions, const std::vector<int> &instanceValues,
			const std::vector<ParamDecl> &params, const std::vector<TestDesc> &tests);
		~Report();

		std::ostream &WriteToLua(std::ostream &stream, const char *suite_name,
			const char *suite_desc, const char *gl_version, const char *gl_vendor,
			const char *gl_renderer) const;

	private:
		boost::scoped_ptr<ReportData> m_pData;

		friend class TestDatum;
		friend std::ostream &operator<<(std::ostream &stream, const Report &report);

		TestDatumElement &GetDatumElement(const std::string &testName, int instance, int execution);

		std::ostream &DisplayWriter(std::ostream &stream) const;
	};

	//Simple output stream writer. Not meant for later processing.
	inline std::ostream &operator<<(std::ostream &stream, const Report &report) {return report.DisplayWriter(stream);}

	void TestMethod( const char * val );
	enum TestDatumId
	{
		DATUM_CPU_ELAPSED = 0,
		DATUM_GPU_ELAPSED,
		DATUM_GPU_LATENCY,

		NUM_TOTAL_DATUM,
	};

	class TestDatum : public boost::noncopyable
	{
	public:
		TestDatum(Report &report, const std::string &testName, int instance, int execution);

		void SetValue(TestDatumId eId, double value);

	private:
		TestDatumElement &data;
	};
}

#endif //PERFORMANCE_REPORT_H