@node-projects/speedscope 0.0.0-stage → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,150 @@
1
+ // This file contains types which specify the speedscope file format.
2
+
3
+ export namespace FileFormat {
4
+ export type Profile = EventedProfile | SampledProfile
5
+
6
+ export interface File {
7
+ $schema: 'https://www.speedscope.app/file-format-schema.json'
8
+
9
+ // Data shared between profiles
10
+ shared: {
11
+ frames: Frame[]
12
+ }
13
+
14
+ // List of profile definitions
15
+ profiles: Profile[]
16
+
17
+ // The name of the contained profile group. If omitted, will use the name of
18
+ // the file itself.
19
+ // Added in 0.6.0
20
+ name?: string
21
+
22
+ // The index into the `profiles` array that should be displayed upon file
23
+ // load. If omitted, will default to displaying the first profile in the
24
+ // file.
25
+ //
26
+ // Added in 0.6.0
27
+ activeProfileIndex?: number
28
+
29
+ // The name of the the program which exported this profile. This isn't
30
+ // consumed but can be helpful for debugging generated data by seeing what
31
+ // was generating it! Recommended format is "name@version". e.g. when the
32
+ // file was exported by speedscope v0.6.0 itself, it will be
33
+ // "speedscope@0.6.0"
34
+ //
35
+ // Added in 0.6.0
36
+ exporter?: string
37
+ }
38
+
39
+ export interface Frame {
40
+ name: string
41
+ file?: string
42
+ line?: number
43
+ col?: number
44
+ }
45
+
46
+ export enum ProfileType {
47
+ EVENTED = 'evented',
48
+ SAMPLED = 'sampled',
49
+ }
50
+
51
+ export interface IProfile {
52
+ // Optional fork metadata. Aggregate-only profiles have no time-order axis.
53
+ // Omitted values preserve compatibility with existing speedscope files.
54
+ isChronological?: boolean
55
+ // Derived profiles are excluded when combining original captures again.
56
+ isDerived?: boolean
57
+ // Type of profile. This will future proof the file format to allow many
58
+ // different kinds of profiles to be contained and each type to be part of
59
+ // a discriminated union.
60
+ type: ProfileType
61
+ }
62
+
63
+ export interface EventedProfile extends IProfile {
64
+ type: ProfileType.EVENTED
65
+
66
+ // Name of the profile. Typically a filename for the source of the profile.
67
+ name: string
68
+
69
+ // Unit which all value are specified using in the profile.
70
+ unit: ValueUnit
71
+
72
+ // The starting value of the profile. This will typically be a timestamp.
73
+ // All event values will be displayed relative to this startValue.
74
+ startValue: number
75
+
76
+ // The final value of the profile. This will typically be a timestamp. This
77
+ // must be greater than or equal to the startValue. This is useful in
78
+ // situations where the recorded profile extends past the end of the recorded
79
+ // events, which may happen if nothing was happening at the end of the
80
+ // profile.
81
+ endValue: number
82
+
83
+ // List of events that occured as part of this profile.
84
+ // The "at" field of every event must be in non-decreasing order.
85
+ events: (OpenFrameEvent | CloseFrameEvent)[]
86
+ }
87
+
88
+ // List of indices into the frame array
89
+ type SampledStack = number[]
90
+
91
+ export interface SampledProfile extends IProfile {
92
+ type: ProfileType.SAMPLED
93
+
94
+ // Name of the profile. Typically a filename for the source of the profile.
95
+ name: string
96
+
97
+ // Unit which all value are specified using in the profile.
98
+ unit: ValueUnit
99
+
100
+ // The starting value of the profile. This will typically be a timestamp.
101
+ // All event values will be displayed relative to this startValue.
102
+ startValue: number
103
+
104
+ // The final value of the profile. This will typically be a timestamp. This
105
+ // must be greater than or equal to the startValue. This is useful in
106
+ // situations where the recorded profile extends past the end of the recorded
107
+ // events, which may happen if nothing was happening at the end of the
108
+ // profile.
109
+ endValue: number
110
+
111
+ // List of stacks
112
+ samples: SampledStack[]
113
+
114
+ // The weight of the sample at the given index. Should have
115
+ // the same length as the samples array.
116
+ weights: number[]
117
+ }
118
+
119
+ export type ValueUnit =
120
+ | 'none'
121
+ | 'nanoseconds'
122
+ | 'microseconds'
123
+ | 'milliseconds'
124
+ | 'seconds'
125
+ | 'bytes'
126
+
127
+ export enum EventType {
128
+ OPEN_FRAME = 'O',
129
+ CLOSE_FRAME = 'C',
130
+ }
131
+
132
+ interface IEvent {
133
+ type: EventType
134
+ at: number
135
+ }
136
+
137
+ // Indicates a stack frame opened. Every opened stack frame must have a
138
+ // corresponding close frame event, and the ordering must be balanced.
139
+ interface OpenFrameEvent extends IEvent {
140
+ type: EventType.OPEN_FRAME
141
+ // An index into the frames array in the shared data within the profile
142
+ frame: number
143
+ }
144
+
145
+ interface CloseFrameEvent extends IEvent {
146
+ type: EventType.CLOSE_FRAME
147
+ // An index into the frames array in the shared data within the profile
148
+ frame: number
149
+ }
150
+ }