Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 <cstring> | 5 #include <cstring> |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 EXPECT_SUBSTRING("\"ph\":\"X\"", js.ToCString()); | 168 EXPECT_SUBSTRING("\"ph\":\"X\"", js.ToCString()); |
| 169 // Check that ts key is present. | 169 // Check that ts key is present. |
| 170 EXPECT_SUBSTRING("\"ts\":", js.ToCString()); | 170 EXPECT_SUBSTRING("\"ts\":", js.ToCString()); |
| 171 // Check that dur key is present. | 171 // Check that dur key is present. |
| 172 EXPECT_SUBSTRING("\"dur\":", js.ToCString()); | 172 EXPECT_SUBSTRING("\"dur\":", js.ToCString()); |
| 173 } | 173 } |
| 174 event.DurationEnd(); | 174 event.DurationEnd(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 TEST_CASE(TimelineEventPrintSystrace) { | |
| 179 const intptr_t kBufferLength = 1024; | |
| 180 char buffer[kBufferLength]; | |
| 181 | |
| 182 // Create a test stream. | |
| 183 TimelineStream stream; | |
| 184 stream.Init("testStream", true); | |
| 185 | |
| 186 // Create a test event. | |
| 187 TimelineEvent event; | |
| 188 TimelineTestHelper::SetStream(&event, &stream); | |
| 189 | |
| 190 // Test a Begin event. | |
| 191 event.Begin("apple", 1, 2); | |
| 192 event.PrintSystrace(&buffer[0], kBufferLength); | |
| 193 EXPECT_SUBSTRING("|apple", buffer); | |
| 194 EXPECT_SUBSTRING("B|", buffer); | |
| 195 | |
| 196 // Test an End event. | |
| 197 event.End("apple", 2, 3); | |
| 198 event.PrintSystrace(&buffer[0], kBufferLength); | |
| 199 EXPECT_STREQ("E", buffer); | |
| 200 | |
| 201 // Test a Counter event. We only report the first counter value (in this case | |
| 202 // "4"). | |
| 203 event.Counter("CTR", 1); | |
| 204 // We have two counters. | |
| 205 event.SetNumArguments(2); | |
| 206 // Set the first counter value. | |
| 207 event.CopyArgument(0, "cats", "4"); | |
| 208 // Set the second counter value. | |
| 209 event.CopyArgument(1, "dogs", "1"); | |
| 210 event.PrintSystrace(&buffer[0], kBufferLength); | |
| 211 EXPECT_SUBSTRING("C|", buffer); | |
| 212 EXPECT_SUBSTRING("|CTR|4", buffer); | |
| 213 | |
| 214 // Test a duration event. This event kind is not supported so we should | |
|
rmacnak
2016/09/08 18:17:09
Most of our events are durations, maybe we should
Cutch
2016/09/08 18:24:08
Chinmay and I discussed this and we've decided to
| |
| 215 // serialize it to an empty string. | |
| 216 event.Duration("DUR", 0, 1, 2, 3); | |
| 217 event.PrintSystrace(&buffer[0], kBufferLength); | |
| 218 EXPECT_STREQ("", buffer); | |
| 219 } | |
| 220 | |
| 221 | |
| 178 TEST_CASE(TimelineEventArguments) { | 222 TEST_CASE(TimelineEventArguments) { |
| 179 // Create a test stream. | 223 // Create a test stream. |
| 180 TimelineStream stream; | 224 TimelineStream stream; |
| 181 stream.Init("testStream", true); | 225 stream.Init("testStream", true); |
| 182 | 226 |
| 183 // Create a test event. | 227 // Create a test event. |
| 184 TimelineEvent event; | 228 TimelineEvent event; |
| 185 TimelineTestHelper::SetStream(&event, &stream); | 229 TimelineTestHelper::SetStream(&event, &stream); |
| 186 | 230 |
| 187 // Allocate room for four arguments. | 231 // Allocate room for four arguments. |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 pauses.Setup(); | 896 pauses.Setup(); |
| 853 pauses.CalculatePauseTimesForThread(tid); | 897 pauses.CalculatePauseTimesForThread(tid); |
| 854 EXPECT(pauses.has_error()); | 898 EXPECT(pauses.has_error()); |
| 855 } | 899 } |
| 856 TimelineTestHelper::Clear(recorder); | 900 TimelineTestHelper::Clear(recorder); |
| 857 } | 901 } |
| 858 | 902 |
| 859 #endif // !PRODUCT | 903 #endif // !PRODUCT |
| 860 | 904 |
| 861 } // namespace dart | 905 } // namespace dart |
| OLD | NEW |