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

Unified Diff: test/cctest/test-global-handles.cc

Issue 2066693003: NOT FOR LANDING. Perf test of global handle Reset operation. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: x Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-global-handles.cc
diff --git a/test/cctest/test-global-handles.cc b/test/cctest/test-global-handles.cc
index 06e7466dc68fa7727d9379fae24cfd60b135b570..6c2d2d089aacee7a14bc4cefbd2c8fd5d388bbb7 100644
--- a/test/cctest/test-global-handles.cc
+++ b/test/cctest/test-global-handles.cc
@@ -469,3 +469,44 @@ TEST(PhatomHandlesWithoutCallbacks) {
CHECK_EQ(2, isolate->NumberOfPhantomHandleResetsSinceLastCall());
CHECK_EQ(0, isolate->NumberOfPhantomHandleResetsSinceLastCall());
}
+
+const int N = 1000000;
+v8::Global<v8::Object> gs[N];
+
+TEST(HandleResetPerf) {
+ CcTest::InitializeVM();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ std::vector<int> permutation;
+ for (int i = 0; i < N; i++) {
+ permutation.push_back(i);
+ }
+ // Comment it out to make clearing in-order.
+ std::random_shuffle(permutation.begin(), permutation.end());
+ v8::Local<v8::Object> o = v8::Object::New(isolate);
+ double t1 = CcTest::i_isolate()->heap()->MonotonicallyIncreasingTimeInMs();
+ for (int i = 0; i < N; i++) {
+ gs[i].Reset(isolate, o);
+ }
+ double t2 = CcTest::i_isolate()->heap()->MonotonicallyIncreasingTimeInMs();
+ int sum = 0;
+ for (int i = 0; i < N; i++) {
+ sum += permutation[i];
+ gs[permutation[i]].Reset();
+ }
+ double t3 = CcTest::i_isolate()->heap()->MonotonicallyIncreasingTimeInMs();
+ for (int i = 0; i < N; i++) {
+ gs[i].Reset(isolate, o);
+ }
+ double t4 = CcTest::i_isolate()->heap()->MonotonicallyIncreasingTimeInMs();
+ for (int i = 0; i < N; i++) {
+ sum += permutation[i];
+ gs[i].Reset();
+ }
+ double t5 = CcTest::i_isolate()->heap()->MonotonicallyIncreasingTimeInMs();
+ printf("allocation1 %.3f\n", t2 - t1);
+ printf("clear1 %.3f\n", t3 - t2);
+ printf("alloaction2 %.3f\n", t4 - t3);
+ printf("clear2 %.3f\n", t5 - t4);
+ printf("sum %d\n", sum);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698