OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 TEST(CollectCpuProfile) { | 543 TEST(CollectCpuProfile) { |
544 LocalContext env; | 544 LocalContext env; |
545 v8::HandleScope scope(env->GetIsolate()); | 545 v8::HandleScope scope(env->GetIsolate()); |
546 | 546 |
547 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 547 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
548 cpu_profiler_test_source))->Run(); | 548 cpu_profiler_test_source))->Run(); |
549 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 549 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
550 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 550 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
551 | 551 |
552 int32_t profiling_interval_ms = 200; | 552 int32_t profiling_interval_ms = 200; |
553 v8::Handle<v8::Value> args[] = { | 553 v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; |
554 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | |
555 }; | |
556 const v8::CpuProfile* profile = | 554 const v8::CpuProfile* profile = |
557 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); | 555 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); |
558 function->Call(env->Global(), ARRAY_SIZE(args), args); | 556 function->Call(env->Global(), ARRAY_SIZE(args), args); |
559 | 557 |
560 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 558 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
561 | 559 |
562 ScopedVector<v8::Handle<v8::String> > names(3); | 560 ScopedVector<v8::Handle<v8::String> > names(3); |
563 names[0] = v8::String::NewFromUtf8( | 561 names[0] = v8::String::NewFromUtf8( |
564 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 562 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
565 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 563 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 v8::Script::Compile(v8::String::NewFromUtf8( | 615 v8::Script::Compile(v8::String::NewFromUtf8( |
618 env->GetIsolate(), cpu_profiler_test_source2))->Run(); | 616 env->GetIsolate(), cpu_profiler_test_source2))->Run(); |
619 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 617 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
620 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 618 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
621 | 619 |
622 int32_t repeat_count = 100; | 620 int32_t repeat_count = 100; |
623 #if defined(USE_SIMULATOR) | 621 #if defined(USE_SIMULATOR) |
624 // Simulators are much slower. | 622 // Simulators are much slower. |
625 repeat_count = 1; | 623 repeat_count = 1; |
626 #endif | 624 #endif |
627 v8::Handle<v8::Value> args[] = { | 625 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; |
628 v8::Integer::New(env->GetIsolate(), repeat_count) | |
629 }; | |
630 const v8::CpuProfile* profile = | 626 const v8::CpuProfile* profile = |
631 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 627 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); |
632 | 628 |
633 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 629 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
634 | 630 |
635 ScopedVector<v8::Handle<v8::String> > names(3); | 631 ScopedVector<v8::Handle<v8::String> > names(3); |
636 names[0] = v8::String::NewFromUtf8( | 632 names[0] = v8::String::NewFromUtf8( |
637 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 633 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
638 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 634 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
639 ProfileGenerator::kProgramEntryName); | 635 ProfileGenerator::kProgramEntryName); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), | 735 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), |
740 instance); | 736 instance); |
741 | 737 |
742 v8::Script::Compile( | 738 v8::Script::Compile( |
743 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) | 739 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) |
744 ->Run(); | 740 ->Run(); |
745 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 741 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
746 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 742 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
747 | 743 |
748 int32_t repeat_count = 1; | 744 int32_t repeat_count = 1; |
749 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 745 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; |
750 const v8::CpuProfile* profile = | 746 const v8::CpuProfile* profile = |
751 RunProfiler(env, function, args, ARRAY_SIZE(args), 180); | 747 RunProfiler(env, function, args, ARRAY_SIZE(args), 180); |
752 | 748 |
753 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 749 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
754 const v8::CpuProfileNode* startNode = | 750 const v8::CpuProfileNode* startNode = |
755 GetChild(isolate, root, "start"); | 751 GetChild(isolate, root, "start"); |
756 GetChild(isolate, startNode, "get foo"); | 752 GetChild(isolate, startNode, "get foo"); |
757 GetChild(isolate, startNode, "set foo"); | 753 GetChild(isolate, startNode, "set foo"); |
758 | 754 |
759 const_cast<v8::CpuProfile*>(profile)->Delete(); | 755 const_cast<v8::CpuProfile*>(profile)->Delete(); |
(...skipping 28 matching lines...) Expand all Loading... |
788 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) | 784 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) |
789 ->Run(); | 785 ->Run(); |
790 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 786 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
791 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 787 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
792 | 788 |
793 { | 789 { |
794 // Make sure accessors ICs are in monomorphic state before starting | 790 // Make sure accessors ICs are in monomorphic state before starting |
795 // profiling. | 791 // profiling. |
796 accessors.set_warming_up(true); | 792 accessors.set_warming_up(true); |
797 int32_t warm_up_iterations = 3; | 793 int32_t warm_up_iterations = 3; |
798 v8::Handle<v8::Value> args[] = { | 794 v8::Handle<v8::Value> args[] = { v8::Integer::New(warm_up_iterations) }; |
799 v8::Integer::New(isolate, warm_up_iterations) | |
800 }; | |
801 function->Call(env->Global(), ARRAY_SIZE(args), args); | 795 function->Call(env->Global(), ARRAY_SIZE(args), args); |
802 accessors.set_warming_up(false); | 796 accessors.set_warming_up(false); |
803 } | 797 } |
804 | 798 |
805 int32_t repeat_count = 100; | 799 int32_t repeat_count = 100; |
806 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 800 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; |
807 const v8::CpuProfile* profile = | 801 const v8::CpuProfile* profile = |
808 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); | 802 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); |
809 | 803 |
810 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 804 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
811 const v8::CpuProfileNode* startNode = | 805 const v8::CpuProfileNode* startNode = |
812 GetChild(isolate, root, "start"); | 806 GetChild(isolate, root, "start"); |
813 GetChild(isolate, startNode, "get foo"); | 807 GetChild(isolate, startNode, "get foo"); |
814 GetChild(isolate, startNode, "set foo"); | 808 GetChild(isolate, startNode, "set foo"); |
815 | 809 |
816 const_cast<v8::CpuProfile*>(profile)->Delete(); | 810 const_cast<v8::CpuProfile*>(profile)->Delete(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 v8::Local<v8::Object> instance = func->NewInstance(); | 844 v8::Local<v8::Object> instance = func->NewInstance(); |
851 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), | 845 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), |
852 instance); | 846 instance); |
853 | 847 |
854 v8::Script::Compile(v8::String::NewFromUtf8( | 848 v8::Script::Compile(v8::String::NewFromUtf8( |
855 isolate, native_method_test_source))->Run(); | 849 isolate, native_method_test_source))->Run(); |
856 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 850 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
857 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 851 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
858 | 852 |
859 int32_t repeat_count = 1; | 853 int32_t repeat_count = 1; |
860 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 854 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; |
861 const v8::CpuProfile* profile = | 855 const v8::CpuProfile* profile = |
862 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 856 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); |
863 | 857 |
864 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 858 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
865 const v8::CpuProfileNode* startNode = | 859 const v8::CpuProfileNode* startNode = |
866 GetChild(isolate, root, "start"); | 860 GetChild(isolate, root, "start"); |
867 GetChild(isolate, startNode, "fooMethod"); | 861 GetChild(isolate, startNode, "fooMethod"); |
868 | 862 |
869 const_cast<v8::CpuProfile*>(profile)->Delete(); | 863 const_cast<v8::CpuProfile*>(profile)->Delete(); |
870 } | 864 } |
(...skipping 28 matching lines...) Expand all Loading... |
899 | 893 |
900 v8::Script::Compile(v8::String::NewFromUtf8( | 894 v8::Script::Compile(v8::String::NewFromUtf8( |
901 isolate, native_method_test_source))->Run(); | 895 isolate, native_method_test_source))->Run(); |
902 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 896 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
903 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 897 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
904 { | 898 { |
905 // Make sure method ICs are in monomorphic state before starting | 899 // Make sure method ICs are in monomorphic state before starting |
906 // profiling. | 900 // profiling. |
907 callbacks.set_warming_up(true); | 901 callbacks.set_warming_up(true); |
908 int32_t warm_up_iterations = 3; | 902 int32_t warm_up_iterations = 3; |
909 v8::Handle<v8::Value> args[] = { | 903 v8::Handle<v8::Value> args[] = { v8::Integer::New(warm_up_iterations) }; |
910 v8::Integer::New(isolate, warm_up_iterations) | |
911 }; | |
912 function->Call(env->Global(), ARRAY_SIZE(args), args); | 904 function->Call(env->Global(), ARRAY_SIZE(args), args); |
913 callbacks.set_warming_up(false); | 905 callbacks.set_warming_up(false); |
914 } | 906 } |
915 | 907 |
916 int32_t repeat_count = 100; | 908 int32_t repeat_count = 100; |
917 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 909 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; |
918 const v8::CpuProfile* profile = | 910 const v8::CpuProfile* profile = |
919 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 911 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); |
920 | 912 |
921 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 913 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
922 GetChild(isolate, root, "start"); | 914 GetChild(isolate, root, "start"); |
923 const v8::CpuProfileNode* startNode = | 915 const v8::CpuProfileNode* startNode = |
924 GetChild(isolate, root, "start"); | 916 GetChild(isolate, root, "start"); |
925 GetChild(isolate, startNode, "fooMethod"); | 917 GetChild(isolate, startNode, "fooMethod"); |
926 | 918 |
927 const_cast<v8::CpuProfile*>(profile)->Delete(); | 919 const_cast<v8::CpuProfile*>(profile)->Delete(); |
(...skipping 18 matching lines...) Expand all Loading... |
946 LocalContext env; | 938 LocalContext env; |
947 v8::HandleScope scope(env->GetIsolate()); | 939 v8::HandleScope scope(env->GetIsolate()); |
948 | 940 |
949 v8::Script::Compile( | 941 v8::Script::Compile( |
950 v8::String::NewFromUtf8(env->GetIsolate(), bound_function_test_source)) | 942 v8::String::NewFromUtf8(env->GetIsolate(), bound_function_test_source)) |
951 ->Run(); | 943 ->Run(); |
952 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 944 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
953 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 945 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
954 | 946 |
955 int32_t duration_ms = 100; | 947 int32_t duration_ms = 100; |
956 v8::Handle<v8::Value> args[] = { | 948 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; |
957 v8::Integer::New(env->GetIsolate(), duration_ms) | |
958 }; | |
959 const v8::CpuProfile* profile = | 949 const v8::CpuProfile* profile = |
960 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 950 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); |
961 | 951 |
962 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 952 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
963 ScopedVector<v8::Handle<v8::String> > names(3); | 953 ScopedVector<v8::Handle<v8::String> > names(3); |
964 names[0] = v8::String::NewFromUtf8( | 954 names[0] = v8::String::NewFromUtf8( |
965 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 955 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
966 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 956 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
967 ProfileGenerator::kProgramEntryName); | 957 ProfileGenerator::kProgramEntryName); |
968 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 958 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 | 997 |
1008 // Collect garbage that might have be generated while installing extensions. | 998 // Collect garbage that might have be generated while installing extensions. |
1009 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 999 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
1010 | 1000 |
1011 v8::Script::Compile(v8::String::NewFromUtf8( | 1001 v8::Script::Compile(v8::String::NewFromUtf8( |
1012 env->GetIsolate(), call_function_test_source))->Run(); | 1002 env->GetIsolate(), call_function_test_source))->Run(); |
1013 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1003 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
1014 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1004 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
1015 | 1005 |
1016 int32_t duration_ms = 100; | 1006 int32_t duration_ms = 100; |
1017 v8::Handle<v8::Value> args[] = { | 1007 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; |
1018 v8::Integer::New(env->GetIsolate(), duration_ms) | |
1019 }; | |
1020 const v8::CpuProfile* profile = | 1008 const v8::CpuProfile* profile = |
1021 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 1009 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); |
1022 | 1010 |
1023 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1011 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
1024 { | 1012 { |
1025 ScopedVector<v8::Handle<v8::String> > names(4); | 1013 ScopedVector<v8::Handle<v8::String> > names(4); |
1026 names[0] = v8::String::NewFromUtf8( | 1014 names[0] = v8::String::NewFromUtf8( |
1027 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1015 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
1028 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1016 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
1029 ProfileGenerator::kProgramEntryName); | 1017 ProfileGenerator::kProgramEntryName); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 LocalContext env; | 1077 LocalContext env; |
1090 v8::HandleScope scope(env->GetIsolate()); | 1078 v8::HandleScope scope(env->GetIsolate()); |
1091 | 1079 |
1092 v8::Script::Compile( | 1080 v8::Script::Compile( |
1093 v8::String::NewFromUtf8(env->GetIsolate(), function_apply_test_source)) | 1081 v8::String::NewFromUtf8(env->GetIsolate(), function_apply_test_source)) |
1094 ->Run(); | 1082 ->Run(); |
1095 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1083 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
1096 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1084 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
1097 | 1085 |
1098 int32_t duration_ms = 100; | 1086 int32_t duration_ms = 100; |
1099 v8::Handle<v8::Value> args[] = { | 1087 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; |
1100 v8::Integer::New(env->GetIsolate(), duration_ms) | |
1101 }; | |
1102 | 1088 |
1103 const v8::CpuProfile* profile = | 1089 const v8::CpuProfile* profile = |
1104 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 1090 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); |
1105 | 1091 |
1106 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1092 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
1107 { | 1093 { |
1108 ScopedVector<v8::Handle<v8::String> > names(3); | 1094 ScopedVector<v8::Handle<v8::String> > names(3); |
1109 names[0] = v8::String::NewFromUtf8( | 1095 names[0] = v8::String::NewFromUtf8( |
1110 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1096 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
1111 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1097 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); | 1184 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); |
1199 env->Global()->Set( | 1185 env->Global()->Set( |
1200 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); | 1186 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); |
1201 | 1187 |
1202 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 1188 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
1203 js_native_js_test_source))->Run(); | 1189 js_native_js_test_source))->Run(); |
1204 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1190 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
1205 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1191 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
1206 | 1192 |
1207 int32_t duration_ms = 20; | 1193 int32_t duration_ms = 20; |
1208 v8::Handle<v8::Value> args[] = { | 1194 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; |
1209 v8::Integer::New(env->GetIsolate(), duration_ms) | |
1210 }; | |
1211 const v8::CpuProfile* profile = | 1195 const v8::CpuProfile* profile = |
1212 RunProfiler(env, function, args, ARRAY_SIZE(args), 10); | 1196 RunProfiler(env, function, args, ARRAY_SIZE(args), 10); |
1213 | 1197 |
1214 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1198 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
1215 { | 1199 { |
1216 ScopedVector<v8::Handle<v8::String> > names(3); | 1200 ScopedVector<v8::Handle<v8::String> > names(3); |
1217 names[0] = v8::String::NewFromUtf8( | 1201 names[0] = v8::String::NewFromUtf8( |
1218 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1202 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
1219 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1203 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
1220 ProfileGenerator::kProgramEntryName); | 1204 ProfileGenerator::kProgramEntryName); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 env->Global()->Set( | 1268 env->Global()->Set( |
1285 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); | 1269 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); |
1286 | 1270 |
1287 v8::Script::Compile( | 1271 v8::Script::Compile( |
1288 v8::String::NewFromUtf8(env->GetIsolate(), | 1272 v8::String::NewFromUtf8(env->GetIsolate(), |
1289 js_native_js_runtime_js_test_source))->Run(); | 1273 js_native_js_runtime_js_test_source))->Run(); |
1290 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1274 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
1291 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1275 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
1292 | 1276 |
1293 int32_t duration_ms = 20; | 1277 int32_t duration_ms = 20; |
1294 v8::Handle<v8::Value> args[] = { | 1278 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; |
1295 v8::Integer::New(env->GetIsolate(), duration_ms) | |
1296 }; | |
1297 const v8::CpuProfile* profile = | 1279 const v8::CpuProfile* profile = |
1298 RunProfiler(env, function, args, ARRAY_SIZE(args), 10); | 1280 RunProfiler(env, function, args, ARRAY_SIZE(args), 10); |
1299 | 1281 |
1300 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1282 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
1301 ScopedVector<v8::Handle<v8::String> > names(3); | 1283 ScopedVector<v8::Handle<v8::String> > names(3); |
1302 names[0] = v8::String::NewFromUtf8( | 1284 names[0] = v8::String::NewFromUtf8( |
1303 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1285 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
1304 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1286 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
1305 ProfileGenerator::kProgramEntryName); | 1287 ProfileGenerator::kProgramEntryName); |
1306 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 1288 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 env->Global()->Set( | 1361 env->Global()->Set( |
1380 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2); | 1362 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2); |
1381 | 1363 |
1382 v8::Script::Compile( | 1364 v8::Script::Compile( |
1383 v8::String::NewFromUtf8(env->GetIsolate(), | 1365 v8::String::NewFromUtf8(env->GetIsolate(), |
1384 js_native1_js_native2_js_test_source))->Run(); | 1366 js_native1_js_native2_js_test_source))->Run(); |
1385 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1367 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
1386 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1368 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
1387 | 1369 |
1388 int32_t duration_ms = 20; | 1370 int32_t duration_ms = 20; |
1389 v8::Handle<v8::Value> args[] = { | 1371 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; |
1390 v8::Integer::New(env->GetIsolate(), duration_ms) | |
1391 }; | |
1392 const v8::CpuProfile* profile = | 1372 const v8::CpuProfile* profile = |
1393 RunProfiler(env, function, args, ARRAY_SIZE(args), 10); | 1373 RunProfiler(env, function, args, ARRAY_SIZE(args), 10); |
1394 | 1374 |
1395 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1375 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
1396 ScopedVector<v8::Handle<v8::String> > names(3); | 1376 ScopedVector<v8::Handle<v8::String> > names(3); |
1397 names[0] = v8::String::NewFromUtf8( | 1377 names[0] = v8::String::NewFromUtf8( |
1398 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1378 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
1399 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1379 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
1400 ProfileGenerator::kProgramEntryName); | 1380 ProfileGenerator::kProgramEntryName); |
1401 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 1381 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 inner_profile = NULL; | 1548 inner_profile = NULL; |
1569 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1549 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
1570 | 1550 |
1571 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); | 1551 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); |
1572 CHECK(outer_profile); | 1552 CHECK(outer_profile); |
1573 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1553 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
1574 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); | 1554 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); |
1575 outer_profile = NULL; | 1555 outer_profile = NULL; |
1576 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1556 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
1577 } | 1557 } |
OLD | NEW |