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

Unified Diff: runtime/vm/timeline_test.cc

Issue 1294023009: Switch to a VM wide timeline recorder (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« runtime/vm/dart.cc ('K') | « runtime/vm/timeline.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/timeline_test.cc
diff --git a/runtime/vm/timeline_test.cc b/runtime/vm/timeline_test.cc
index 8eb92c6ced64354722db8fedff24e5a585fa677d..6657e04c246a224607493df1d3882c7446d37d42 100644
--- a/runtime/vm/timeline_test.cc
+++ b/runtime/vm/timeline_test.cc
@@ -15,6 +15,22 @@
namespace dart {
+class TimelineRecorderOverride : public ValueObject {
+ public:
+ explicit TimelineRecorderOverride(TimelineEventRecorder* new_recorder)
+ : recorder_(Timeline::recorder()) {
+ Timeline::recorder_ = new_recorder;
+ }
+
+ ~TimelineRecorderOverride() {
+ Timeline::recorder_ = recorder_;
+ }
+
+ private:
+ TimelineEventRecorder* recorder_;
+};
+
+
class TimelineTestHelper : public AllStatic {
public:
static void SetStream(TimelineEvent* event, TimelineStream* stream) {
@@ -53,6 +69,10 @@ class TimelineTestHelper : public AllStatic {
ASSERT(recorder != NULL);
recorder->Clear();
}
+
+ static void FinishBlock(TimelineEventBlock* block) {
+ block->Finish();
+ }
};
@@ -172,10 +192,10 @@ TEST_CASE(TimelineEventArgumentsPrintJSON) {
TEST_CASE(TimelineEventBufferPrintJSON) {
- Isolate* isolate = Isolate::Current();
- TimelineEventRecorder* recorder = isolate->timeline_event_recorder();
+ TimelineEventRecorder* recorder = Timeline::recorder();
JSONStream js;
- recorder->PrintJSON(&js);
+ TimelineEventFilter filter;
+ recorder->PrintJSON(&js, &filter);
// Check the type. This test will fail if we ever make Timeline public.
EXPECT_SUBSTRING("\"type\":\"_Timeline\"", js.ToCString());
// Check that there is a traceEvents array.
@@ -207,6 +227,7 @@ class EventCounterRecorder : public TimelineEventStreamingRecorder {
TEST_CASE(TimelineEventStreamingRecorderBasic) {
EventCounterRecorder* recorder = new EventCounterRecorder();
+ TimelineRecorderOverride override(recorder);
// Initial counts are all zero.
for (intptr_t i = TimelineEvent::kNone + 1;
@@ -218,7 +239,6 @@ TEST_CASE(TimelineEventStreamingRecorderBasic) {
// Create a test stream.
TimelineStream stream;
stream.Init("testStream", true);
- stream.set_recorder(recorder);
TimelineEvent* event = NULL;
@@ -240,8 +260,9 @@ TEST_CASE(TimelineEventStreamingRecorderBasic) {
event = stream.StartEvent();
EXPECT_EQ(0, recorder->CountFor(TimelineEvent::kAsyncBegin));
- int64_t async_id = event->AsyncBegin("asyncBeginCabbage");
+ int64_t async_id = recorder->GetNextAsyncId();
EXPECT(async_id >= 0);
+ event->AsyncBegin("asyncBeginCabbage", async_id);
EXPECT_EQ(0, recorder->CountFor(TimelineEvent::kAsyncBegin));
event->Complete();
EXPECT_EQ(1, recorder->CountFor(TimelineEvent::kAsyncBegin));
@@ -400,8 +421,12 @@ TEST_CASE(TimelineRingRecorderJSONOrder) {
// Emit the later event into block_0.
TimelineTestHelper::FakeThreadEvent(block_0, 2, "Beta", &stream);
+ TimelineTestHelper::FinishBlock(block_0);
+ TimelineTestHelper::FinishBlock(block_1);
+
JSONStream js;
- recorder->PrintJSON(&js);
+ TimelineEventFilter filter;
+ recorder->PrintJSON(&js, &filter);
// trace-event has a requirement that events for a thread must have
// monotonically increasing timestamps.
// Verify that "Alpha" comes before "Beta" even though "Beta" is in the first
« runtime/vm/dart.cc ('K') | « runtime/vm/timeline.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698