@parcel/workers 2.8.3 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
package/src/Trace.js DELETED
@@ -1,125 +0,0 @@
1
- // @flow
2
- import type {Profile} from './Profiler';
3
- import type {Writable} from 'stream';
4
- import {Tracer} from 'chrome-trace-event';
5
-
6
- export default class Trace {
7
- tracer: Tracer;
8
- tid: number;
9
- eventId: number;
10
-
11
- constructor() {
12
- this.tracer = new Tracer();
13
- this.tid = 0;
14
- this.eventId = 0;
15
- }
16
-
17
- getEventId(): number {
18
- return this.eventId++;
19
- }
20
-
21
- init(ts: number) {
22
- this.tracer.instantEvent({
23
- name: 'TracingStartedInPage',
24
- id: this.getEventId(),
25
- ts,
26
- cat: ['disabled-by-default-devtools.timeline'],
27
- args: {
28
- data: {
29
- sessionId: '-1',
30
- page: '0xfff',
31
- frames: [
32
- {
33
- frame: '0xfff',
34
- url: 'parcel',
35
- name: '',
36
- },
37
- ],
38
- },
39
- },
40
- });
41
-
42
- this.tracer.instantEvent({
43
- name: 'TracingStartedInBrowser',
44
- id: this.getEventId(),
45
- ts,
46
- cat: ['disabled-by-default-devtools.timeline'],
47
- args: {
48
- data: {
49
- sessionId: '-1',
50
- },
51
- },
52
- });
53
- }
54
-
55
- addCPUProfile(name: string, profile: Profile) {
56
- if (this.eventId === 0) {
57
- this.init(profile.startTime);
58
- }
59
- const trace = this.tracer;
60
- const tid = this.tid;
61
- this.tid++;
62
-
63
- const cpuStartTime = profile.startTime;
64
- const cpuEndTime = profile.endTime;
65
-
66
- trace.instantEvent({
67
- tid,
68
- id: this.getEventId(),
69
- cat: ['toplevel'],
70
- name: 'TaskQueueManager::ProcessTaskFromWorkQueue',
71
- args: {
72
- src_file: '../../ipc/ipc_moji_bootstrap.cc',
73
- src_func: 'Accept',
74
- },
75
- ts: cpuStartTime,
76
- });
77
-
78
- trace.completeEvent({
79
- tid,
80
- name: 'EvaluateScript',
81
- id: this.getEventId(),
82
- cat: ['devtools.timeline'],
83
- ts: cpuStartTime,
84
- dur: cpuEndTime - cpuStartTime,
85
- args: {
86
- data: {
87
- url: 'parcel',
88
- lineNumber: 1,
89
- columnNumber: 1,
90
- frame: '0xFFF',
91
- },
92
- },
93
- });
94
-
95
- trace.instantEvent({
96
- tid,
97
- ts: 0,
98
- ph: 'M',
99
- cat: ['__metadata'],
100
- name: 'thread_name',
101
- args: {name},
102
- });
103
-
104
- trace.instantEvent({
105
- tid,
106
- name: 'CpuProfile',
107
- id: this.getEventId(),
108
- cat: ['disabled-by-default-devtools.timeline'],
109
- ts: cpuEndTime,
110
- args: {
111
- data: {
112
- cpuProfile: profile,
113
- },
114
- },
115
- });
116
- }
117
-
118
- pipe(writable: Writable): stream$Writable {
119
- return this.tracer.pipe(writable);
120
- }
121
-
122
- flush() {
123
- this.tracer.push(null);
124
- }
125
- }