コード例 #1
0
std::ostream & TestsListener::errorsLog()
{
  if (theInstance().verbose)
    return theInstance().outputter->errorsLog();
  else
  {
    theInstance().devNull.str("");
    return theInstance().devNull;
  }
}
コード例 #2
0
ファイル: test_timer.cpp プロジェクト: hossainmurad/mycppcgi
  clock_t Timer::stopTimer    ( const String & name )
  {
    std::map<String, clock_t>::const_iterator cit= theInstance().timeRecorder.find( name );

    clock_t result= clock();

    if ( cit != theInstance().timeRecorder.end() )
      result -= cit->second;

    return result;
  }
コード例 #3
0
void TestsListener::testHasStarted()
{
  //std::cout << ".";
  ++theInstance().executed;
  theInstance().executionComment= "";

  if (theInstance().timing)
  {
    Timer::startTest(testFullName());
  }

}
コード例 #4
0
clock_t Timer::stopTest(const String & test)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);

  if (cit != theInstance().timeRecorder.end())
  {
    clock_t now=clock();
    theInstance().timeRecorder[test].cpu=now - theInstance().timeRecorder[test].cpu;
    return theInstance().timeRecorder[test].cpu;
  }

  return static_cast<clock_t> (-1);
}
コード例 #5
0
clock_t Timer::startTest(const String & test)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);

  if (cit == theInstance().timeRecorder.end())
  {
    theInstance().currentTest=test;
    test_timer t=test_timer();
    theInstance().timeRecorder[test]=t;
    return theInstance().timeRecorder[test].cpu;
  }

  return static_cast<clock_t> (-1);
}
コード例 #6
0
const String Timer::getFile(const String & test, const String & name)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);
  if (cit == theInstance().timeRecorder.end())
    // unknown test - must not happen
    return 0;

  std::map<String, timer>::const_iterator it=theInstance().timeRecorder[test].timers.find(name);

  if (it == theInstance().timeRecorder[test].timers.end())
    // unknown timer
    return 0;

  return theInstance().timeRecorder[test].timers[name].file;
}
コード例 #7
0
clock_t Timer::getTime(const String & test, const String & name)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);
  if (cit == theInstance().timeRecorder.end())
    // unknown test - must not happen
    return static_cast<clock_t> (-1);

  std::map<String, timer>::const_iterator it=theInstance().timeRecorder[test].timers.find(name);

  if (it == theInstance().timeRecorder[test].timers.end())
    // unknown timer
    return static_cast<clock_t> (-1);


  return theInstance().timeRecorder[test].timers[name].total_cpu;
}
コード例 #8
0
const List & Timer::getNames()
{
  static List names;

  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find("perf_statement::anonymousSelect");
  std::map<String, timer>::const_iterator it;

  for (; cit != theInstance().timeRecorder.end(); ++cit)
  {
    for (it=theInstance().timeRecorder[cit->first].timers.begin(); it != theInstance().timeRecorder[cit->first].timers.end(); ++it)
    {
      names.push_back(it->first);
    }
  }

  return names;
}
コード例 #9
0
const List & Timer::getNames(const String & test)
{
  static List names;

  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);
  if (cit == theInstance().timeRecorder.end())
  {
    return names;
  }
  std::map<String, timer>::const_iterator it;

  for (it=theInstance().timeRecorder[cit->first].timers.begin(); it != theInstance().timeRecorder[cit->first].timers.end(); ++it)
  {
    names.push_back(it->first);
  }

  return names;
}
コード例 #10
0
void TestsListener::nextSuiteStarts(const String & name, int testsNumber)
{
  /*
  if ( name.length() > 0 )
      theInstance().messagesLog()
        << "=============== " << name << " ends. " << "==============="
        << std::endl;*/



  theInstance().curSuiteName=name;

  /*
  theInstance().messagesLog()
      << "=============== " << name << " starts. " << "==============="
      << std::endl;*/


  theInstance().outputter->SuiteHeader(name, theInstance().curTestOrdNum + 1
                                       , testsNumber);
}
コード例 #11
0
void VisualDebugger::updatePvdProperties(const PxTriangleMesh* triMesh)
{
	PVD::PvdCommLayerError error;

	bool hasMatIndex = triMesh->getTriangleMaterialIndex(0) != 0xffff;
	PxU64 theInstance(PX_PROFILE_POINTER_TO_U64(triMesh));
	
	// update arrays:
	// vertex Array:
	{ 
		const PxU8* vertexPtr = reinterpret_cast<const PxU8*>(triMesh->getVertices());
		const PxU32 vertexStride = sizeof(PxVec3);
		const PxU32 numVertices = triMesh->getNbVertices();
		error = PvdConnectionHelper::sendSingleElementArrayProperty(mPvdConnection, theInstance, TriangleMeshProp::VertexArray
																 , VectorArrayProp::Element, PVD::PvdCommLayerDatatype::Float3
																 , vertexPtr, vertexStride, numVertices);
		PX_ASSERT(error == PVD::PvdCommLayerError::None);
	}

	// index Array:
	{
		const bool has16BitIndices = triMesh->has16BitTriangleIndices();
		const PxU8* trianglePtr = reinterpret_cast<const PxU8*>(triMesh->getTriangles());
		const PxU32 triangleStride = has16BitIndices ? sizeof(PxU16)* 3 : sizeof(PxU32)* 3;
		const PxU32 numTriangles = triMesh->getNbTriangles();

		mPvdConnectionHelper.sendPrimitiveIndexArrayProperty(mPvdConnection, theInstance, TriangleMeshProp::TriangleIndexArray
															, trianglePtr, triangleStride, numTriangles, 3, has16BitIndices);
		

		PX_ASSERT(error == PVD::PvdCommLayerError::None);
	}

	// material Array:
	if(hasMatIndex)
	{
		PxU32 numMaterials = triMesh->getNbTriangles();
		PvdConnectionHelper::beginSingleElementArrayProperty(mPvdConnection, theInstance, TriangleMeshProp::TriangleMaterialArray, U16ArrayProp::Element, PVD::PvdCommLayerDatatype::U16);

		for(PxU32 m = 0; m < numMaterials; m++)
		{
			PVD::PvdCommLayerValue theValue(triMesh->getTriangleMaterialIndex(m));
			error = mPvdConnection->sendArrayObject(&theValue);
		}

		error = mPvdConnection->endArrayPropertyBlock();
		PX_ASSERT(error == PVD::PvdCommLayerError::None);
	}
}
コード例 #12
0
clock_t Timer::stopTimer(const String & test, const String & name)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);
  if (cit == theInstance().timeRecorder.end())
    // unknown test - must not happen
    return static_cast<clock_t> (-1);

  std::map<String, timer>::const_iterator it=theInstance().timeRecorder[test].timers.find(name);

  if (it == theInstance().timeRecorder[test].timers.end())
    // unknown timer
    return static_cast<clock_t> (-1);

  if (theInstance().timeRecorder[test].timers[name].stopped)
    // has been stopped before
    return static_cast<clock_t> (-1);

  clock_t runtime=clock() - theInstance().timeRecorder[test].timers[name].start;
  theInstance().timeRecorder[test].timers[name].stopped=true;
  theInstance().timeRecorder[test].timers[name].total_cpu+=runtime;
  theInstance().timeRecorder[test].timers[name].start=static_cast<clock_t> (0);

  return runtime;
}
コード例 #13
0
clock_t Timer::startTimer(const String & test, const String & name, const String & file, const unsigned int line)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);
  if (cit == theInstance().timeRecorder.end())
    // unknown test - must not happen
    return static_cast<clock_t> (-1);

  std::map<String, timer>::const_iterator it=theInstance().timeRecorder[test].timers.find(name);

  clock_t now=clock();
  if (it == theInstance().timeRecorder[test].timers.end())
  {
    timer t=timer(now, file, line);
    theInstance().timeRecorder[test].timers[name]=t;
  }
  else
  {
    /* TODO: API semantics are somewhat unclear - not sure what is best */
    theInstance().timeRecorder[test].timers[name].start=now;
    theInstance().timeRecorder[name].timers[name].stopped=false;
  }

  return theInstance().timeRecorder[name].timers[name].start;
}
コード例 #14
0
void TestsListener::testHasThrown()
{
	std::cout << "E";
	theInstance()._exceptions++;
}
コード例 #15
0
void TestsListener::testHasFinished(TestRunResult result, const String & msg)
{
  static String timingResult("");

  if (theInstance().timing)
  {

    clock_t time=Timer::stopTest(testFullName());
    float total = Timer::translate2seconds(time);

    static std::stringstream tmp;

    tmp.precision(10);
    tmp.str("");
    tmp << std::showpoint;
    tmp << std::endl << "# " << std::setw(40) << std::left << "Total" << " = ";
    tmp << std::setw(13) << std::right << total << "s";
    tmp << " (100.00%)" << std::endl;

    const List & names=Timer::getNames(testFullName());
    ConstIterator it=names.begin();
    for (; it != names.end(); ++it)
    {
      time=Timer::getTime(*it);
      tmp << "#   " << std::setw(38) << std::left << *it;
      tmp << " = " << std::setw(13) << std::right << Timer::translate2seconds(time) << "s";

      tmp << " (";
      tmp << std::setw(6) << std::right;
      if (total > 0.0) {
        tmp.precision(5);
        tmp << ((100 / total) * Timer::translate2seconds(time));
        tmp.precision(10);
      } else {
        tmp << "n/a ";
      }
      tmp << "%)";

      tmp << " (line " << Timer::getLine(*it) << ")" << std::endl;
    }

    timingResult=tmp.str();
  }
  else
    timingResult="";

  if (!msg.empty())
    StringUtils::concatSeparated(theInstance().executionComment, msg);
  if (!timingResult.empty())
    StringUtils::concatSeparated(theInstance().executionComment, timingResult);

  if (result != trrPassed)
  {
    // Output about test fail and recording info

    theInstance().recordFailed();

    if (result == trrThrown)
      ++theInstance().exceptions;

    theInstance().outputter->TestFailed(theInstance().curTestOrdNum
                                        , theInstance().curTestName
                                        , theInstance().executionComment);
  }
  else
  {
    // Output about test success
    theInstance().outputter->TestPassed(theInstance().curTestOrdNum
                                        , theInstance().curTestName
                                        , theInstance().executionComment);
  }
}
コード例 #16
0
void TestsListener::incrementCounter(int incrVal)
{
  theInstance().curTestOrdNum+=incrVal;
}
コード例 #17
0
clock_t Timer::getTime(const String &name)
{
  return getTime(theInstance().currentTest, name);
}
コード例 #18
0
const String & TestsListener::currentSuiteName()
{
  return theInstance().curSuiteName;
}
コード例 #19
0
String TestsListener::testFullName()
{
  return theInstance().curSuiteName + "::" + theInstance().curTestName;
}
コード例 #20
0
void TestsListener::messagesLog(const String & msg)
{
  if (theInstance().verbose)
    messagesLog() << msg;
}
コード例 #21
0
void TestsListener::currentTestName(const String & name)
{
  theInstance().curTestName=name;
}
コード例 #22
0
clock_t Timer::stopTimer(const String & name)
{
  // hack
  return stopTimer(theInstance().currentTest, name);
}
コード例 #23
0
unsigned int Timer::getLine(const String &name)
{
  return getLine(theInstance().currentTest, name);
}
コード例 #24
0
void TestsListener::setTestExecutionComment(const String & msg)
{
  theInstance().executionComment= msg;
}
コード例 #25
0
void TestsListener::bailSuite(const String & reason)
{
  static const String bail("BAIL ");
  theInstance().outputter->Comment(bail + reason);
}
コード例 #26
0
const String Timer::getFile(const String &name)
{
  return getFile(theInstance().currentTest, name);
}
コード例 #27
0
bool TestsListener::allTestsPassed()
{
  return theInstance().exceptions && !theInstance().failed() == 0;
}
コード例 #28
0
bool TestsListener::allTestsPassed()
{
	return !theInstance()._exceptions && !theInstance()._failed;
}
コード例 #29
0
void TestsListener::setVerbose(bool verbosity)
{
  theInstance().verbose=verbosity;
}
コード例 #30
0
clock_t Timer::startTimer(const String & name, const String & file, const unsigned int line)
{
  // HACK
  return startTimer(theInstance().currentTest, name, file, line);
}