| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_EDK_SYSTEM_TEST_UTILS_H_ | |
| 6 #define MOJO_EDK_SYSTEM_TEST_UTILS_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/time/time.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 namespace system { | |
| 13 namespace test { | |
| 14 | |
| 15 // A timeout smaller than |TestTimeouts::tiny_timeout()|. Warning: This may lead | |
| 16 // to flakiness, but this is unavoidable if, e.g., you're trying to ensure that | |
| 17 // functions with timeouts are reasonably accurate. We want this to be as small | |
| 18 // as possible without causing too much flakiness. | |
| 19 base::TimeDelta EpsilonTimeout(); | |
| 20 | |
| 21 // Stopwatch ------------------------------------------------------------------- | |
| 22 | |
| 23 // A simple "stopwatch" for measuring time elapsed from a given starting point. | |
| 24 class Stopwatch { | |
| 25 public: | |
| 26 Stopwatch() {} | |
| 27 ~Stopwatch() {} | |
| 28 | |
| 29 void Start() { start_time_ = base::TimeTicks::Now(); } | |
| 30 | |
| 31 base::TimeDelta Elapsed() { return base::TimeTicks::Now() - start_time_; } | |
| 32 | |
| 33 private: | |
| 34 base::TimeTicks start_time_; | |
| 35 | |
| 36 DISALLOW_COPY_AND_ASSIGN(Stopwatch); | |
| 37 }; | |
| 38 | |
| 39 } // namespace test | |
| 40 } // namespace system | |
| 41 } // namespace mojo | |
| 42 | |
| 43 #endif // MOJO_EDK_SYSTEM_TEST_UTILS_H_ | |
| OLD | NEW |