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

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

Issue 23621056: Initial in-process implementation of some Mojo primitives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 7 years, 2 months 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
(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 #include "mojo/public/tests/test_support.h"
6
7 #include "base/test/perf_log.h"
8 #include "base/time/time.h"
9 #include "mojo/system/core_impl.h"
10
11 namespace mojo {
12 namespace test {
13
14 TestBase::TestBase() {
15 }
16
17 TestBase::~TestBase() {
18 }
19
20 void TestBase::SetUp() {
21 if (!system::CoreImpl::Get())
22 system::CoreImpl::Init();
23 }
24
25 void IterateAndReportPerf(const char* test_name,
26 base::Callback<void()> single_iteration) {
27 // TODO(vtl): These should be specifiable using command-line flags.
28 static const size_t kGranularity = 100;
29 static const double kPerftestTimeSeconds = 3.0;
30
31 const base::TimeTicks start_time = base::TimeTicks::HighResNow();
32 base::TimeTicks end_time;
33 size_t iterations = 0;
34 do {
35 for (size_t i = 0; i < kGranularity; i++)
36 single_iteration.Run();
37 iterations += kGranularity;
38
39 end_time = base::TimeTicks::HighResNow();
40 } while ((end_time - start_time).InSecondsF() < kPerftestTimeSeconds);
41
42 base::LogPerfResult(test_name,
43 iterations / (end_time - start_time).InSecondsF(),
44 "iterations/second");
45 }
46
47 } // namespace test
48 } // namespace mojo
OLDNEW
« mojo/mojo.gyp ('K') | « mojo/public/tests/test_support.h ('k') | mojo/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698