| 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);
|
| +}
|
|
|