99 lines
No EOL
4.1 KiB
C++
99 lines
No EOL
4.1 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// File : perftest_logger.h
|
|
// Author : Dominic Morin
|
|
// Date : 2013-05-28
|
|
// Copyright (c) Ubisoft Entertainment. All rights reserved.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#pragma once
|
|
#ifndef _GEAR_TESTING__PERFORMANCE__PERFTEST_LOGGER_H_
|
|
#define _GEAR_TESTING__PERFORMANCE__PERFTEST_LOGGER_H_
|
|
|
|
#include <gear_core/base/ealallocator.h>
|
|
#include <gear_core/base/singleton.h>
|
|
#include <gear_core/generics/gearstring.h>
|
|
#include <gear_core/generics/vector.h>
|
|
#include <tinyxml2/tinyxml2.h>
|
|
|
|
#define MAX_PERFTEST_LOGGER_LEVEL 5
|
|
|
|
namespace G4
|
|
{
|
|
/// Use this logger to add performance tests results to the Tracker
|
|
/*! The fields available in Tracker are:
|
|
- action ("Performance Testing")
|
|
- name (appName, eg: Gear, Havok, gear_core)
|
|
- version (eg: 3.21, 4.0RC)
|
|
- stat (performance test result: unit execution time [usec], eg: 45.13)
|
|
- message (moduleName, eg: math, container)
|
|
- message2 (className, eg: Vector2f, Array<T, N>)
|
|
- data (function signature, eg: "G4::Vector3d::Cross(Vector3d&, const Vector3d&, const Vector3d&)" )
|
|
*/
|
|
class PerfTestLogger
|
|
{
|
|
G4_DECLARE_DYNAMIC_SINGLETON(PerfTestLogger);
|
|
public:
|
|
|
|
/// (Setup level 1 to 3 nodes) Verify the content of a_testCaseName after "perf_" to determine the app name (default is gear_core), the module name and finaly class name
|
|
/*!
|
|
\param a_testCaseName name of the test case class (eg: "perf_havok_math_matrix33f", "perf_math_vector3d")
|
|
\return True on success
|
|
*/
|
|
Bool SetTestCase(const GearString& a_testCaseName);
|
|
|
|
/// (Level 1) First node to add: Add the node containing the name of the application to test
|
|
/*! \param a_appName the application to test. eg: Gear, Havok, gear_core
|
|
\param a_version eg: 3.21, 4.0RC, 2013
|
|
\return True on success
|
|
*/
|
|
Bool SetAppName(const char* a_appName, const char* a_version);
|
|
|
|
/// (Level 2) Child of the last application node added.
|
|
/*! \param a_module name of the module being tested. eg: math, container
|
|
\return True on success
|
|
*/
|
|
Bool SetModuleName(const char* a_module);
|
|
|
|
/// (Level 3) Child of the last module node added.
|
|
/*! \param a_class name of the class being tested. eg: Vector2d, Array<int,16>
|
|
\return True on success
|
|
*/
|
|
Bool SetClassName(const char* a_class);
|
|
|
|
/// (Level 4 [1/2]) Child of the last class node added. Initialize test with function name
|
|
/*! \param a_function the name of the function being tested. eg: "Vector3d_IsValid"
|
|
\param a_testResult average absolute time in nanoseconds for one occurrence
|
|
\return True on success
|
|
*/
|
|
Bool LogTestName(const GearString& a_function);
|
|
|
|
/// (Level 4 [2/2]) Child of the last class node added. Add result to the last function name added with LogTestName
|
|
/*! \param a_testResult average absolute time in nanoseconds for one occurrence
|
|
\return True on success
|
|
*/
|
|
Bool LogTestResult(double a_testResult);
|
|
|
|
private:
|
|
/// Add a child to node m_xmlTree[a_Level - 1] and make m_xmlTree[a_Level] point to it.
|
|
/*!
|
|
\param a_level The height of the xml tree. Level 0 is the root. Use level 1 and over to keep a single root.
|
|
\param a_node The xml node to add
|
|
*/
|
|
Bool AddXmlNode(unsigned char a_level, const char* name, const unsigned int nbAttributes);
|
|
|
|
tinyxml2::XMLDocument m_xmlDoc;
|
|
|
|
/// m_xmlTree[0] contains the root of the tree (xml declaration)
|
|
/// The following nodes in the vector (m_xmlTree[idx]) are the current node at level idx
|
|
/// For instance, adding a node to level 4 of the tree will add a child (m_xmlTree[4]) to node m_xmlTree[3]
|
|
typedef Vector<tinyxml2::XMLNode*, EalAllocator<EAL_ID_TG_GEAR_TESTING> > XMLTree;
|
|
XMLTree m_xmlTree;
|
|
|
|
GearString m_currentFunction;
|
|
|
|
};
|
|
|
|
} //namespace G4
|
|
|
|
#endif //_GEAR_TESTING__PERFORMANCE__PERFTEST_LOGGER_H_
|