Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
timeline_macos.cc
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
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.
4
5#include "vm/globals.h"
6#if defined(DART_HOST_OS_MACOS) && defined(SUPPORT_TIMELINE)
7
8#include "vm/log.h"
9#include "vm/timeline.h"
10
11namespace dart {
12
13TimelineEventMacosRecorder::TimelineEventMacosRecorder()
14 : TimelineEventPlatformRecorder() {
15 Timeline::set_recorder_discards_clock_values(true);
16}
17
18TimelineEventMacosRecorder::~TimelineEventMacosRecorder() {}
19
20void TimelineEventMacosRecorder::OnEvent(TimelineEvent* event) {
21 if (event == nullptr) {
22 return;
23 }
24
25 os_log_t log = event->stream_->macos_log();
26 if (!os_signpost_enabled(log)) {
27 return;
28 }
29
30 const char* label = event->label();
31 bool is_static_label = event->stream_->has_static_labels();
32 uint8_t _Alignas(16) buffer[64];
33 buffer[0] = 0;
34
36 case TimelineEvent::kInstant:
37 if (is_static_label) {
38 _os_signpost_emit_with_name_impl(&__dso_handle, log, OS_SIGNPOST_EVENT,
39 OS_SIGNPOST_ID_EXCLUSIVE, label, "",
40 buffer, sizeof(buffer));
41 } else {
42 os_signpost_event_emit(log, OS_SIGNPOST_ID_EXCLUSIVE, "Event", "%s",
43 label);
44 }
45 break;
46 case TimelineEvent::kBegin:
47 case TimelineEvent::kAsyncBegin:
48 if (is_static_label) {
49 _os_signpost_emit_with_name_impl(
50 &__dso_handle, log, OS_SIGNPOST_INTERVAL_BEGIN, event->Id(), label,
51 "", buffer, sizeof(buffer));
52 } else {
53 os_signpost_interval_begin(log, event->Id(), "Event", "%s", label);
54 }
55 break;
56 case TimelineEvent::kEnd:
57 case TimelineEvent::kAsyncEnd:
58 if (is_static_label) {
59 _os_signpost_emit_with_name_impl(&__dso_handle, log,
60 OS_SIGNPOST_INTERVAL_END, event->Id(),
61 label, "", buffer, sizeof(buffer));
62 } else {
63 os_signpost_interval_end(log, event->Id(), "Event");
64 }
65 break;
66 case TimelineEvent::kCounter:
67 os_signpost_event_emit(log, OS_SIGNPOST_ID_EXCLUSIVE, "Counter", "%s=%s",
68 label, event->arguments()[0].value);
69 break;
70 default:
71 break;
72 }
73}
74
75} // namespace dart
76
77#endif // defined(DART_HOST_OS_MACOS) && defined(SUPPORT_TIMELINE)
ax::mojom::Event event_type
FlKeyEvent * event
static const uint8_t buffer[]
switch(prop_id)