github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/convert/speedscope/json.go (about)

     1  package speedscope
     2  
     3  // Description of Speedscope JSON
     4  // See spec: https://github.com/jlfwong/speedscope/blob/main/src/lib/file-format-spec.ts
     5  
     6  const (
     7  	schema = "https://www.speedscope.app/file-format-schema.json"
     8  
     9  	profileEvented = "evented"
    10  	profileSampled = "sampled"
    11  
    12  	eventOpen  = "O"
    13  	eventClose = "C"
    14  )
    15  
    16  type speedscopeFile struct {
    17  	Schema             string `json:"$schema"`
    18  	Shared             shared
    19  	Profiles           []profile
    20  	Name               string
    21  	ActiveProfileIndex float64
    22  	Exporter           string
    23  }
    24  
    25  type shared struct {
    26  	Frames []frame
    27  }
    28  
    29  type frame struct {
    30  	Name string
    31  	File string
    32  	Line float64
    33  	Col  float64
    34  }
    35  
    36  type profile struct {
    37  	Type       string
    38  	Name       string
    39  	Unit       unit
    40  	StartValue float64
    41  	EndValue   float64
    42  
    43  	// Evented profile
    44  	Events []event
    45  
    46  	// Sample profile
    47  	Samples []sample
    48  	Weights []float64
    49  }
    50  
    51  type event struct {
    52  	Type  string
    53  	At    float64
    54  	Frame float64
    55  }
    56  
    57  // Indexes into Frames
    58  type sample []float64