Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: mojo/public/tests/test_support.cc

Issue 68203005: Mojo: Make tests under mojo/public use our own run_all_unittests.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/tests/test_support.h" 5 #include "mojo/public/tests/test_support.h"
6 6
7 #include "base/test/perf_log.h" 7 #include "base/test/perf_log.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "mojo/system/core_impl.h"
10 9
11 namespace mojo { 10 namespace mojo {
12 namespace test { 11 namespace test {
13 12
14 TestBase::TestBase() {
15 if (!system::CoreImpl::Get())
16 system::CoreImpl::Init();
17 }
18
19 TestBase::~TestBase() {
20 }
21
22 void IterateAndReportPerf(const char* test_name, 13 void IterateAndReportPerf(const char* test_name,
23 base::Callback<void()> single_iteration) { 14 base::Callback<void()> single_iteration) {
24 // TODO(vtl): These should be specifiable using command-line flags. 15 // TODO(vtl): These should be specifiable using command-line flags.
25 static const size_t kGranularity = 100; 16 static const size_t kGranularity = 100;
26 static const double kPerftestTimeSeconds = 3.0; 17 static const double kPerftestTimeSeconds = 3.0;
27 18
28 const base::TimeTicks start_time = base::TimeTicks::HighResNow(); 19 const base::TimeTicks start_time = base::TimeTicks::HighResNow();
29 base::TimeTicks end_time; 20 base::TimeTicks end_time;
30 size_t iterations = 0; 21 size_t iterations = 0;
31 do { 22 do {
32 for (size_t i = 0; i < kGranularity; i++) 23 for (size_t i = 0; i < kGranularity; i++)
33 single_iteration.Run(); 24 single_iteration.Run();
34 iterations += kGranularity; 25 iterations += kGranularity;
35 26
36 end_time = base::TimeTicks::HighResNow(); 27 end_time = base::TimeTicks::HighResNow();
37 } while ((end_time - start_time).InSecondsF() < kPerftestTimeSeconds); 28 } while ((end_time - start_time).InSecondsF() < kPerftestTimeSeconds);
38 29
39 base::LogPerfResult(test_name, 30 base::LogPerfResult(test_name,
40 iterations / (end_time - start_time).InSecondsF(), 31 iterations / (end_time - start_time).InSecondsF(),
41 "iterations/second"); 32 "iterations/second");
42 } 33 }
43 34
44 } // namespace test 35 } // namespace test
45 } // namespace mojo 36 } // namespace mojo
OLDNEW
« mojo/public/tests/bindings_connector_unittest.cc ('K') | « mojo/public/tests/test_support.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698