Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | #ifndef mozilla__ipdltest_TestLatency_h |
michael@0 | 2 | #define mozilla__ipdltest_TestLatency_h 1 |
michael@0 | 3 | |
michael@0 | 4 | #include "mozilla/_ipdltest/IPDLUnitTests.h" |
michael@0 | 5 | |
michael@0 | 6 | #include "mozilla/_ipdltest/PTestLatencyParent.h" |
michael@0 | 7 | #include "mozilla/_ipdltest/PTestLatencyChild.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/TimeStamp.h" |
michael@0 | 10 | |
michael@0 | 11 | #define NR_TRIALS 10000 |
michael@0 | 12 | #define NR_SPAMS 25000 |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace _ipdltest { |
michael@0 | 16 | |
michael@0 | 17 | class TestLatencyParent : |
michael@0 | 18 | public PTestLatencyParent |
michael@0 | 19 | { |
michael@0 | 20 | private: |
michael@0 | 21 | typedef mozilla::TimeStamp TimeStamp; |
michael@0 | 22 | typedef mozilla::TimeDuration TimeDuration; |
michael@0 | 23 | |
michael@0 | 24 | public: |
michael@0 | 25 | TestLatencyParent(); |
michael@0 | 26 | virtual ~TestLatencyParent(); |
michael@0 | 27 | |
michael@0 | 28 | static bool RunTestInProcesses() { return true; } |
michael@0 | 29 | static bool RunTestInThreads() { return true; } |
michael@0 | 30 | |
michael@0 | 31 | void Main(); |
michael@0 | 32 | |
michael@0 | 33 | protected: |
michael@0 | 34 | virtual bool RecvPong() MOZ_OVERRIDE; |
michael@0 | 35 | virtual bool RecvPong5() MOZ_OVERRIDE; |
michael@0 | 36 | |
michael@0 | 37 | virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE |
michael@0 | 38 | { |
michael@0 | 39 | if (NormalShutdown != why) |
michael@0 | 40 | fail("unexpected destruction!"); |
michael@0 | 41 | |
michael@0 | 42 | passed("\n" |
michael@0 | 43 | " average #ping-pong/sec: %g\n" |
michael@0 | 44 | " average #ping5-pong5/sec: %g\n" |
michael@0 | 45 | " average #RPC call-answer/sec: %g\n" |
michael@0 | 46 | " average #spams/sec: %g\n" |
michael@0 | 47 | " pct. spams compressed away: %g\n", |
michael@0 | 48 | double(NR_TRIALS) / mPPTimeTotal.ToSecondsSigDigits(), |
michael@0 | 49 | double(NR_TRIALS) / mPP5TimeTotal.ToSecondsSigDigits(), |
michael@0 | 50 | double(NR_TRIALS) / mRpcTimeTotal.ToSecondsSigDigits(), |
michael@0 | 51 | double(NR_SPAMS) / mSpamTimeTotal.ToSecondsSigDigits(), |
michael@0 | 52 | 100.0 * (double(NR_SPAMS - mNumChildProcessedCompressedSpams) / |
michael@0 | 53 | double(NR_SPAMS))); |
michael@0 | 54 | |
michael@0 | 55 | QuitParent(); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | private: |
michael@0 | 59 | void PingPongTrial(); |
michael@0 | 60 | void Ping5Pong5Trial(); |
michael@0 | 61 | void RpcTrials(); |
michael@0 | 62 | void SpamTrial(); |
michael@0 | 63 | void CompressedSpamTrial(); |
michael@0 | 64 | void Exit(); |
michael@0 | 65 | |
michael@0 | 66 | TimeStamp mStart; |
michael@0 | 67 | TimeDuration mPPTimeTotal; |
michael@0 | 68 | TimeDuration mPP5TimeTotal; |
michael@0 | 69 | TimeDuration mRpcTimeTotal; |
michael@0 | 70 | TimeDuration mSpamTimeTotal; |
michael@0 | 71 | |
michael@0 | 72 | int mPPTrialsToGo; |
michael@0 | 73 | int mPP5TrialsToGo; |
michael@0 | 74 | uint32_t mNumChildProcessedCompressedSpams; |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | |
michael@0 | 78 | class TestLatencyChild : |
michael@0 | 79 | public PTestLatencyChild |
michael@0 | 80 | { |
michael@0 | 81 | public: |
michael@0 | 82 | TestLatencyChild(); |
michael@0 | 83 | virtual ~TestLatencyChild(); |
michael@0 | 84 | |
michael@0 | 85 | protected: |
michael@0 | 86 | virtual bool RecvPing() MOZ_OVERRIDE; |
michael@0 | 87 | virtual bool RecvPing5() MOZ_OVERRIDE; |
michael@0 | 88 | virtual bool AnswerRpc() MOZ_OVERRIDE; |
michael@0 | 89 | virtual bool RecvSpam() MOZ_OVERRIDE; |
michael@0 | 90 | virtual bool AnswerSynchro() MOZ_OVERRIDE; |
michael@0 | 91 | virtual bool RecvCompressedSpam(const uint32_t& seqno) MOZ_OVERRIDE; |
michael@0 | 92 | virtual bool AnswerSynchro2(uint32_t* lastSeqno, |
michael@0 | 93 | uint32_t* numMessagesDispatched) MOZ_OVERRIDE; |
michael@0 | 94 | |
michael@0 | 95 | virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE |
michael@0 | 96 | { |
michael@0 | 97 | if (NormalShutdown != why) |
michael@0 | 98 | fail("unexpected destruction!"); |
michael@0 | 99 | QuitChild(); |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | uint32_t mLastSeqno; |
michael@0 | 103 | uint32_t mNumProcessedCompressedSpams; |
michael@0 | 104 | }; |
michael@0 | 105 | |
michael@0 | 106 | |
michael@0 | 107 | } // namespace _ipdltest |
michael@0 | 108 | } // namespace mozilla |
michael@0 | 109 | |
michael@0 | 110 | |
michael@0 | 111 | #endif // ifndef mozilla__ipdltest_TestLatency_h |