2009-10-13 15:36:28 -07:00
|
|
|
#ifndef mozilla__ipdltest_TestLatency_h
|
|
|
|
#define mozilla__ipdltest_TestLatency_h 1
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
#include "mozilla/_ipdltest/IPDLUnitTests.h"
|
2009-10-13 15:36:28 -07:00
|
|
|
|
|
|
|
#include "mozilla/_ipdltest/PTestLatencyParent.h"
|
|
|
|
#include "mozilla/_ipdltest/PTestLatencyChild.h"
|
|
|
|
|
2009-10-13 21:08:24 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
#define NR_TRIALS 10000
|
2010-08-05 15:11:23 -07:00
|
|
|
#define NR_SPAMS 50000
|
2009-12-03 00:16:28 -08:00
|
|
|
|
2009-10-13 15:36:28 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace _ipdltest {
|
|
|
|
|
|
|
|
class TestLatencyParent :
|
|
|
|
public PTestLatencyParent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
|
|
|
typedef mozilla::TimeDuration TimeDuration;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TestLatencyParent();
|
|
|
|
virtual ~TestLatencyParent();
|
|
|
|
|
|
|
|
void Main();
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
protected:
|
|
|
|
NS_OVERRIDE
|
2009-10-13 15:36:28 -07:00
|
|
|
virtual bool RecvPong();
|
2009-12-03 00:16:28 -08:00
|
|
|
NS_OVERRIDE
|
2009-10-13 15:36:28 -07:00
|
|
|
virtual bool RecvPong5();
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
if (NormalShutdown != why)
|
|
|
|
fail("unexpected destruction!");
|
|
|
|
|
2010-08-05 15:11:23 -07:00
|
|
|
passed("\n"
|
|
|
|
" average #ping-pong/sec: %g\n"
|
|
|
|
" average #ping5-pong5/sec: %g\n"
|
|
|
|
" average #RPC call-answer/sec: %g\n"
|
|
|
|
" average #spams/sec: %g\n",
|
|
|
|
double(NR_TRIALS) / mPPTimeTotal.ToSecondsSigDigits(),
|
|
|
|
double(NR_TRIALS) / mPP5TimeTotal.ToSecondsSigDigits(),
|
|
|
|
double(NR_TRIALS) / mRpcTimeTotal.ToSecondsSigDigits(),
|
|
|
|
double(NR_SPAMS) / mSpamTimeTotal.ToSecondsSigDigits());
|
2009-12-03 00:16:28 -08:00
|
|
|
|
|
|
|
QuitParent();
|
|
|
|
}
|
|
|
|
|
2009-10-13 15:36:28 -07:00
|
|
|
private:
|
|
|
|
void PingPongTrial();
|
|
|
|
void Ping5Pong5Trial();
|
2010-02-04 19:40:42 -08:00
|
|
|
void RpcTrials();
|
2010-08-05 15:11:23 -07:00
|
|
|
void SpamTrial();
|
2009-10-13 15:36:28 -07:00
|
|
|
void Exit();
|
|
|
|
|
|
|
|
TimeStamp mStart;
|
|
|
|
TimeDuration mPPTimeTotal;
|
|
|
|
TimeDuration mPP5TimeTotal;
|
2010-02-04 19:40:42 -08:00
|
|
|
TimeDuration mRpcTimeTotal;
|
2010-08-05 15:11:23 -07:00
|
|
|
TimeDuration mSpamTimeTotal;
|
2009-10-13 15:36:28 -07:00
|
|
|
|
|
|
|
int mPPTrialsToGo;
|
|
|
|
int mPP5TrialsToGo;
|
2010-08-05 15:11:23 -07:00
|
|
|
int mSpamsToGo;
|
2009-10-13 15:36:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TestLatencyChild :
|
|
|
|
public PTestLatencyChild
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TestLatencyChild();
|
|
|
|
virtual ~TestLatencyChild();
|
|
|
|
|
|
|
|
protected:
|
2009-12-03 00:16:28 -08:00
|
|
|
NS_OVERRIDE
|
2009-10-13 15:36:28 -07:00
|
|
|
virtual bool RecvPing();
|
2009-12-03 00:16:28 -08:00
|
|
|
NS_OVERRIDE
|
2009-10-13 15:36:28 -07:00
|
|
|
virtual bool RecvPing5();
|
2010-02-04 19:40:42 -08:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool AnswerRpc();
|
2010-08-05 15:11:23 -07:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool RecvSpam();
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool AnswerSynchro();
|
2009-12-03 00:16:28 -08:00
|
|
|
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
if (NormalShutdown != why)
|
|
|
|
fail("unexpected destruction!");
|
|
|
|
QuitChild();
|
|
|
|
}
|
2009-10-13 15:36:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace _ipdltest
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ifndef mozilla__ipdltest_TestLatency_h
|