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

Side by Side Diff: mojo/public/cpp/test_support/lib/test_utils.cc

Issue 795593004: Update mojo sdk to rev cc531b32182099a5a034a99daff35ed5d38a61c8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More workarounds for MSVC Created 5 years, 11 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
« no previous file with comments | « mojo/public/cpp/system/tests/BUILD.gn ('k') | mojo/public/cpp/test_support/test_support.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cpp/test_support/test_utils.h" 5 #include "mojo/public/cpp/test_support/test_utils.h"
6 6
7 #include "mojo/public/cpp/system/core.h" 7 #include "mojo/public/cpp/system/core.h"
8 #include "mojo/public/cpp/test_support/test_support.h" 8 #include "mojo/public/cpp/test_support/test_support.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 MojoResult rv = ReadMessageRaw(handle, 62 MojoResult rv = ReadMessageRaw(handle,
63 nullptr, 63 nullptr,
64 nullptr, 64 nullptr,
65 nullptr, 65 nullptr,
66 nullptr, 66 nullptr,
67 MOJO_READ_MESSAGE_FLAG_MAY_DISCARD); 67 MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
68 return rv == MOJO_RESULT_OK; 68 return rv == MOJO_RESULT_OK;
69 } 69 }
70 70
71 void IterateAndReportPerf(const char* test_name, 71 void IterateAndReportPerf(const char* test_name,
72 const char* sub_test_name,
72 PerfTestSingleIteration single_iteration, 73 PerfTestSingleIteration single_iteration,
73 void* closure) { 74 void* closure) {
74 // TODO(vtl): These should be specifiable using command-line flags. 75 // TODO(vtl): These should be specifiable using command-line flags.
75 static const size_t kGranularity = 100; 76 static const size_t kGranularity = 100;
76 static const MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000; 77 static const MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000;
77 78
78 const MojoTimeTicks start_time = GetTimeTicksNow(); 79 const MojoTimeTicks start_time = GetTimeTicksNow();
79 MojoTimeTicks end_time; 80 MojoTimeTicks end_time;
80 size_t iterations = 0; 81 size_t iterations = 0;
81 do { 82 do {
82 for (size_t i = 0; i < kGranularity; i++) 83 for (size_t i = 0; i < kGranularity; i++)
83 (*single_iteration)(closure); 84 (*single_iteration)(closure);
84 iterations += kGranularity; 85 iterations += kGranularity;
85 86
86 end_time = GetTimeTicksNow(); 87 end_time = GetTimeTicksNow();
87 } while (end_time - start_time < kPerftestTimeMicroseconds); 88 } while (end_time - start_time < kPerftestTimeMicroseconds);
88 89
89 MojoTestSupportLogPerfResult(test_name, 90 MojoTestSupportLogPerfResult(test_name, sub_test_name,
90 1000000.0 * iterations / (end_time - start_time), 91 1000000.0 * iterations / (end_time - start_time),
91 "iterations/second"); 92 "iterations/second");
92 } 93 }
93 94
94 } // namespace test 95 } // namespace test
95 } // namespace mojo 96 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/tests/BUILD.gn ('k') | mojo/public/cpp/test_support/test_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698