Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/profiler.h" | 10 #include "vm/profiler.h" |
| (...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2802 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); | 2802 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); |
| 2803 | 2803 |
| 2804 // Verify positions in main. | 2804 // Verify positions in main. |
| 2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); | 2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); |
| 2806 // Verify exclusive ticks in main. | 2806 // Verify exclusive ticks in main. |
| 2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); | 2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); |
| 2808 // Verify inclusive ticks in main. | 2808 // Verify inclusive ticks in main. |
| 2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); | 2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); |
| 2810 } | 2810 } |
| 2811 | 2811 |
| 2812 | |
| 2813 TEST_CASE(Profiler_ProfileCodeTableTest) { | |
| 2814 Zone* Z = Thread::Current()->zone(); | |
| 2815 | |
| 2816 ProfileCodeTable* table = new (Z) ProfileCodeTable(); | |
| 2817 EXPECT_EQ(table->length(), 0); | |
| 2818 EXPECT_EQ(table->FindCodeForPC(42), static_cast<ProfileCode*>(NULL)); | |
| 2819 | |
| 2820 int64_t timestamp = 0; | |
| 2821 Code& null_code = Code::Handle(Z); | |
| 2822 | |
| 2823 ProfileCode* code1 = new (Z) | |
| 2824 ProfileCode(ProfileCode::kNativeCode, 50, 60, timestamp, null_code); | |
| 2825 EXPECT_EQ(table->InsertCode(code1), 0); | |
| 2826 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
|
zra
2017/06/14 17:49:22
Maybe try intermediate and end values here and bel
rmacnak
2017/06/14 18:14:08
Added
| |
| 2827 | |
| 2828 // Insert below all. | |
| 2829 ProfileCode* code2 = new (Z) | |
| 2830 ProfileCode(ProfileCode::kNativeCode, 10, 20, timestamp, null_code); | |
| 2831 EXPECT_EQ(table->InsertCode(code2), 0); | |
| 2832 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
| 2833 EXPECT_EQ(table->FindCodeForPC(10), code2); | |
| 2834 | |
| 2835 // Insert above all. | |
| 2836 ProfileCode* code3 = new (Z) | |
| 2837 ProfileCode(ProfileCode::kNativeCode, 80, 90, timestamp, null_code); | |
| 2838 EXPECT_EQ(table->InsertCode(code3), 2); | |
| 2839 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
| 2840 EXPECT_EQ(table->FindCodeForPC(10), code2); | |
| 2841 EXPECT_EQ(table->FindCodeForPC(80), code3); | |
| 2842 | |
| 2843 // Insert between. | |
| 2844 ProfileCode* code4 = new (Z) | |
| 2845 ProfileCode(ProfileCode::kNativeCode, 65, 75, timestamp, null_code); | |
| 2846 EXPECT_EQ(table->InsertCode(code4), 2); | |
| 2847 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
| 2848 EXPECT_EQ(table->FindCodeForPC(10), code2); | |
| 2849 EXPECT_EQ(table->FindCodeForPC(80), code3); | |
| 2850 EXPECT_EQ(table->FindCodeForPC(65), code4); | |
| 2851 | |
| 2852 // Insert overlapping left. | |
| 2853 ProfileCode* code5 = new (Z) | |
| 2854 ProfileCode(ProfileCode::kNativeCode, 15, 25, timestamp, null_code); | |
| 2855 EXPECT_EQ(table->InsertCode(code5), 0); | |
| 2856 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
| 2857 EXPECT_EQ(table->FindCodeForPC(10), code2); | |
| 2858 EXPECT_EQ(table->FindCodeForPC(80), code3); | |
| 2859 EXPECT_EQ(table->FindCodeForPC(65), code4); | |
| 2860 EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left. | |
| 2861 EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left. | |
| 2862 | |
| 2863 // Insert overlapping right. | |
| 2864 ProfileCode* code6 = new (Z) | |
| 2865 ProfileCode(ProfileCode::kNativeCode, 45, 55, timestamp, null_code); | |
| 2866 EXPECT_EQ(table->InsertCode(code6), 1); | |
| 2867 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
| 2868 EXPECT_EQ(table->FindCodeForPC(10), code2); | |
| 2869 EXPECT_EQ(table->FindCodeForPC(80), code3); | |
| 2870 EXPECT_EQ(table->FindCodeForPC(65), code4); | |
| 2871 EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left. | |
| 2872 EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left. | |
| 2873 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right. | |
| 2874 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right. | |
| 2875 | |
| 2876 // Insert overlapping both. | |
| 2877 ProfileCode* code7 = new (Z) | |
| 2878 ProfileCode(ProfileCode::kNativeCode, 20, 50, timestamp, null_code); | |
| 2879 EXPECT_EQ(table->InsertCode(code7), 0); | |
| 2880 EXPECT_EQ(table->FindCodeForPC(50), code1); | |
| 2881 EXPECT_EQ(table->FindCodeForPC(10), code2); | |
| 2882 EXPECT_EQ(table->FindCodeForPC(80), code3); | |
| 2883 EXPECT_EQ(table->FindCodeForPC(65), code4); | |
| 2884 EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left. | |
| 2885 EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left. | |
| 2886 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right. | |
| 2887 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right. | |
| 2888 EXPECT_EQ(table->FindCodeForPC(20), code2); // Merged left. | |
| 2889 EXPECT_EQ(table->FindCodeForPC(49), code1); // Truncated. | |
| 2890 } | |
| 2891 | |
| 2812 #endif // !PRODUCT | 2892 #endif // !PRODUCT |
| 2813 | 2893 |
| 2814 } // namespace dart | 2894 } // namespace dart |
| OLD | NEW |