Bug 581930: Add an async "spam test" and make output more readable. r=NPOTB (alas!)

This commit is contained in:
Chris Jones 2010-08-05 17:11:23 -05:00
parent 9de8956b51
commit 215c42366a
3 changed files with 73 additions and 20 deletions

View File

@ -10,6 +10,8 @@ child:
Ping(); Ping();
Ping5(); Ping5();
rpc Rpc(); rpc Rpc();
Spam();
rpc Synchro();
parent: parent:
Pong(); Pong();
@ -45,8 +47,16 @@ state PONG3: recv Pong5 goto PONG4;
state PONG4: recv Pong5 goto PONG5; state PONG4: recv Pong5 goto PONG5;
state PONG5: recv Pong5 goto PING5; state PONG5: recv Pong5 goto PING5;
// Trial 3: lotsa RPC
state RPC: state RPC:
call Rpc goto RPC; call Rpc goto RPC;
send Spam goto SPAM;
state SPAM:
send Spam goto SPAM;
call Synchro goto DONE;
state DONE:
send __delete__; send __delete__;
}; };

View File

@ -18,7 +18,8 @@ TestLatencyParent::TestLatencyParent() :
mPP5TimeTotal(), mPP5TimeTotal(),
mRpcTimeTotal(), mRpcTimeTotal(),
mPPTrialsToGo(NR_TRIALS), mPPTrialsToGo(NR_TRIALS),
mPP5TrialsToGo(NR_TRIALS) mPP5TrialsToGo(NR_TRIALS),
mSpamsToGo(NR_TRIALS)
{ {
MOZ_COUNT_CTOR(TestLatencyParent); MOZ_COUNT_CTOR(TestLatencyParent);
} }
@ -68,12 +69,6 @@ TestLatencyParent::Ping5Pong5Trial()
fail("sending Ping5()"); fail("sending Ping5()");
} }
void
TestLatencyParent::Exit()
{
Close();
}
bool bool
TestLatencyParent::RecvPong() TestLatencyParent::RecvPong()
{ {
@ -115,23 +110,47 @@ TestLatencyParent::RecvPong5()
void void
TestLatencyParent::RpcTrials() TestLatencyParent::RpcTrials()
{ {
TimeStamp start = TimeStamp::Now();
for (int i = 0; i < NR_TRIALS; ++i) { for (int i = 0; i < NR_TRIALS; ++i) {
TimeStamp start = TimeStamp::Now();
if (!CallRpc()) if (!CallRpc())
fail("can't call Rpc()"); fail("can't call Rpc()");
TimeDuration thisTrial = (TimeStamp::Now() - start);
if (0 == (i % 1000)) if (0 == (i % 1000))
printf(" Rpc trial %d: %g\n", i, thisTrial.ToSecondsSigDigits()); printf(" Rpc trial %d\n", i);
}
mRpcTimeTotal = (TimeStamp::Now() - start);
mRpcTimeTotal += thisTrial; SpamTrial();
}
void
TestLatencyParent::SpamTrial()
{
TimeStamp start = TimeStamp::Now();
for (int i = 0; i < NR_SPAMS - 1; ++i) {
if (!SendSpam())
fail("sending Spam()");
if (0 == (i % 10000))
printf(" Spam trial %d\n", i);
} }
// Synchronize with the child process to ensure all messages have
// been processed. This adds the overhead of a reply message from
// child-->here, but should be insignificant compared to >>
// NR_SPAMS.
if (!CallSynchro())
fail("calling Synchro()");
mSpamTimeTotal = (TimeStamp::Now() - start);
Exit(); Exit();
} }
void
TestLatencyParent::Exit()
{
Close();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// child // child
@ -174,5 +193,18 @@ TestLatencyChild::AnswerRpc()
return true; return true;
} }
bool
TestLatencyChild::RecvSpam()
{
// no-op
return true;
}
bool
TestLatencyChild::AnswerSynchro()
{
return true;
}
} // namespace _ipdltest } // namespace _ipdltest
} // namespace mozilla } // namespace mozilla

View File

@ -9,6 +9,7 @@
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#define NR_TRIALS 10000 #define NR_TRIALS 10000
#define NR_SPAMS 50000
namespace mozilla { namespace mozilla {
namespace _ipdltest { namespace _ipdltest {
@ -38,12 +39,15 @@ protected:
if (NormalShutdown != why) if (NormalShutdown != why)
fail("unexpected destruction!"); fail("unexpected destruction!");
passed("average ping/pong latency: %g sec, " passed("\n"
"average ping5/pong5 latency: %g sec, " " average #ping-pong/sec: %g\n"
"average RPC call/answer: %g sec", " average #ping5-pong5/sec: %g\n"
mPPTimeTotal.ToSecondsSigDigits() / (double) NR_TRIALS, " average #RPC call-answer/sec: %g\n"
mPP5TimeTotal.ToSecondsSigDigits() / (double) NR_TRIALS, " average #spams/sec: %g\n",
mRpcTimeTotal.ToSecondsSigDigits() / (double) NR_TRIALS); double(NR_TRIALS) / mPPTimeTotal.ToSecondsSigDigits(),
double(NR_TRIALS) / mPP5TimeTotal.ToSecondsSigDigits(),
double(NR_TRIALS) / mRpcTimeTotal.ToSecondsSigDigits(),
double(NR_SPAMS) / mSpamTimeTotal.ToSecondsSigDigits());
QuitParent(); QuitParent();
} }
@ -52,15 +56,18 @@ private:
void PingPongTrial(); void PingPongTrial();
void Ping5Pong5Trial(); void Ping5Pong5Trial();
void RpcTrials(); void RpcTrials();
void SpamTrial();
void Exit(); void Exit();
TimeStamp mStart; TimeStamp mStart;
TimeDuration mPPTimeTotal; TimeDuration mPPTimeTotal;
TimeDuration mPP5TimeTotal; TimeDuration mPP5TimeTotal;
TimeDuration mRpcTimeTotal; TimeDuration mRpcTimeTotal;
TimeDuration mSpamTimeTotal;
int mPPTrialsToGo; int mPPTrialsToGo;
int mPP5TrialsToGo; int mPP5TrialsToGo;
int mSpamsToGo;
}; };
@ -78,6 +85,10 @@ protected:
virtual bool RecvPing5(); virtual bool RecvPing5();
NS_OVERRIDE NS_OVERRIDE
virtual bool AnswerRpc(); virtual bool AnswerRpc();
NS_OVERRIDE
virtual bool RecvSpam();
NS_OVERRIDE
virtual bool AnswerSynchro();
NS_OVERRIDE NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why) virtual void ActorDestroy(ActorDestroyReason why)