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

Side by Side Diff: mojo/edk/system/ref_counted_perftest.cc

Issue 1430593005: EDK: Remove (direct) dependencies of //mojo/edk/system on //base/test. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/edk/system/message_pipe_perftest.cc ('k') | mojo/edk/system/run_all_unittests.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/test/perf_log.h"
8 #include "mojo/edk/system/ref_counted.h" 7 #include "mojo/edk/system/ref_counted.h"
8 #include "mojo/edk/system/test/perf_log.h"
9 #include "mojo/edk/system/test/stopwatch.h" 9 #include "mojo/edk/system/test/stopwatch.h"
10 #include "mojo/edk/system/test/timeouts.h" 10 #include "mojo/edk/system/test/timeouts.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace system { 14 namespace system {
15 namespace { 15 namespace {
16 16
17 class MyClass : public RefCountedThreadSafe<MyClass> { 17 class MyClass : public RefCountedThreadSafe<MyClass> {
18 public: 18 public:
(...skipping 14 matching lines...) Expand all
33 stopwatch.Start(); 33 stopwatch.Start();
34 do { 34 do {
35 for (size_t i = 0; i < 1000; i++, iterations++) { 35 for (size_t i = 0; i < 1000; i++, iterations++) {
36 RefPtr<MyClass> x = MyClass::Create(); 36 RefPtr<MyClass> x = MyClass::Create();
37 x = nullptr; 37 x = nullptr;
38 } 38 }
39 iterations++; 39 iterations++;
40 } while (stopwatch.Elapsed() < test::DeadlineFromMilliseconds(1000)); 40 } while (stopwatch.Elapsed() < test::DeadlineFromMilliseconds(1000));
41 double elapsed = stopwatch.Elapsed() / 1000000.0; 41 double elapsed = stopwatch.Elapsed() / 1000000.0;
42 42
43 base::LogPerfResult("OneThreadCreateAdoptDestroy", iterations / elapsed, 43 test::LogPerfResult("OneThreadCreateAdoptDestroy", iterations / elapsed,
44 "iterations/s"); 44 "iterations/s");
45 } 45 }
46 46
47 TEST(RefCountedPerfTest, OneThreadAssignRefPtr) { 47 TEST(RefCountedPerfTest, OneThreadAssignRefPtr) {
48 RefPtr<MyClass> x = MyClass::Create(); 48 RefPtr<MyClass> x = MyClass::Create();
49 uint64_t iterations = 0; 49 uint64_t iterations = 0;
50 test::Stopwatch stopwatch; 50 test::Stopwatch stopwatch;
51 stopwatch.Start(); 51 stopwatch.Start();
52 do { 52 do {
53 for (size_t i = 0; i < 1000; i++, iterations++) { 53 for (size_t i = 0; i < 1000; i++, iterations++) {
54 RefPtr<MyClass> y = x; 54 RefPtr<MyClass> y = x;
55 } 55 }
56 iterations++; 56 iterations++;
57 } while (stopwatch.Elapsed() < test::DeadlineFromMilliseconds(1000)); 57 } while (stopwatch.Elapsed() < test::DeadlineFromMilliseconds(1000));
58 double elapsed = stopwatch.Elapsed() / 1000000.0; 58 double elapsed = stopwatch.Elapsed() / 1000000.0;
59 59
60 base::LogPerfResult("OneThreadAssignRefPtr", iterations / elapsed, 60 test::LogPerfResult("OneThreadAssignRefPtr", iterations / elapsed,
61 "iterations/s"); 61 "iterations/s");
62 } 62 }
63 63
64 // TODO(vtl): Add threaded perf tests. 64 // TODO(vtl): Add threaded perf tests.
65 65
66 } // namespace 66 } // namespace
67 } // namespace system 67 } // namespace system
68 } // namespace mojo 68 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_perftest.cc ('k') | mojo/edk/system/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698