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

Unified Diff: base/memory/ref_counted_unittest.cc

Issue 1087083002: [Not for review] scoped_refptr move benchmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/ref_counted.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted_unittest.cc
diff --git a/base/memory/ref_counted_unittest.cc b/base/memory/ref_counted_unittest.cc
index 6f8e599cbdc970728d4a035528f68a4eb69acd9c..00b390fe3f2fac7823c3ac7823d768904f0f4e64 100644
--- a/base/memory/ref_counted_unittest.cc
+++ b/base/memory/ref_counted_unittest.cc
@@ -460,3 +460,49 @@ TEST(RefCountedUnitTest, MoveConstructorDerived) {
EXPECT_EQ(1, ScopedRefPtrCountDerived::destructor_count());
}
+static const int N = 16 * 1000 * 1000;
+
+void BenchmarkUnsafeMove() {
+ scoped_refptr<ThreadUnsafe> p(new ThreadUnsafe());
+ for (int i = 0; i < N; ++i) {
+ p = get_thread_unsafe();
+ }
+}
+
+
+void BenchmarkUnsafeCopy() {
+ scoped_refptr<ThreadUnsafe> p(new ThreadUnsafe());
+ for (int i = 0; i < N; ++i) {
+ p = static_cast<const scoped_refptr<ThreadUnsafe>&>(get_thread_unsafe());
+ }
+}
+
+void BenchmarkSafeMove() {
+ scoped_refptr<ThreadSafe> p(new ThreadSafe());
+ for (int i = 0; i < N; ++i) {
+ p = get_thread_safe();
+ }
+}
+
+void BenchmarkSafeCopy() {
+ scoped_refptr<ThreadSafe> p(new ThreadSafe());
+ for (int i = 0; i < N; ++i) {
+ p = static_cast<const scoped_refptr<ThreadSafe>&>(get_thread_safe());
+ }
+}
+
+TEST(RefCountedUnitTest, BenchmarkUnsafeMove1) {BenchmarkUnsafeMove();}
+TEST(RefCountedUnitTest, BenchmarkUnsafeMove2) {BenchmarkUnsafeMove();}
+TEST(RefCountedUnitTest, BenchmarkUnsafeMove3) {BenchmarkUnsafeMove();}
+
+TEST(RefCountedUnitTest, BenchmarkUnsafeCopy1) {BenchmarkUnsafeCopy();}
+TEST(RefCountedUnitTest, BenchmarkUnsafeCopy2) {BenchmarkUnsafeCopy();}
+TEST(RefCountedUnitTest, BenchmarkUnsafeCopy3) {BenchmarkUnsafeCopy();}
+
+TEST(RefCountedUnitTest, BenchmarkSafeMove1) {BenchmarkSafeMove();}
+TEST(RefCountedUnitTest, BenchmarkSafeMove2) {BenchmarkSafeMove();}
+TEST(RefCountedUnitTest, BenchmarkSafeMove3) {BenchmarkSafeMove();}
+
+TEST(RefCountedUnitTest, BenchmarkSafeCopy1) {BenchmarkSafeCopy();}
+TEST(RefCountedUnitTest, BenchmarkSafeCopy2) {BenchmarkSafeCopy();}
+TEST(RefCountedUnitTest, BenchmarkSafeCopy3) {BenchmarkSafeCopy();}
« no previous file with comments | « base/memory/ref_counted.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698