github.com/grafana/pyroscope@v1.18.0/pkg/pprof/testhelper/model.go (about)

     1  package testhelper
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/google/pprof/profile"
     7  )
     8  
     9  var (
    10  	FooMapping = &profile.Mapping{
    11  		ID:              1,
    12  		Start:           uint64(1),
    13  		Limit:           uint64(2),
    14  		Offset:          uint64(3),
    15  		File:            "foobar.so",
    16  		BuildID:         "v1",
    17  		HasFunctions:    true,
    18  		HasFilenames:    true,
    19  		HasLineNumbers:  true,
    20  		HasInlineFrames: false,
    21  	}
    22  	FooFunction = &profile.Function{
    23  		ID:         1,
    24  		Name:       "foo",
    25  		SystemName: "sfoo",
    26  		Filename:   "foo.go",
    27  		StartLine:  1,
    28  	}
    29  	FooLocation = &profile.Location{
    30  		ID:       1,
    31  		Address:  1,
    32  		IsFolded: false,
    33  		Mapping:  FooMapping,
    34  		Line: []profile.Line{
    35  			{
    36  				Function: FooFunction,
    37  				Line:     100,
    38  			},
    39  		},
    40  	}
    41  	BarFunction = &profile.Function{
    42  		ID:         2,
    43  		Name:       "bar",
    44  		SystemName: "sbar",
    45  		Filename:   "bar.go",
    46  		StartLine:  1,
    47  	}
    48  	BarLocation = &profile.Location{
    49  		ID:       2,
    50  		Address:  2,
    51  		IsFolded: true,
    52  		Mapping:  FooMapping,
    53  		Line: []profile.Line{
    54  			{
    55  				Function: BarFunction,
    56  				Line:     200,
    57  			},
    58  		},
    59  	}
    60  
    61  	FooBarProfile = &profile.Profile{
    62  		SampleType: []*profile.ValueType{
    63  			{Type: "cpu", Unit: "nanoseconds"},
    64  		},
    65  		DefaultSampleType: "cpu",
    66  		Sample: []*profile.Sample{
    67  			{
    68  				Value:    []int64{1},
    69  				Location: []*profile.Location{FooLocation, BarLocation},
    70  			},
    71  			{
    72  				Value:    []int64{2},
    73  				Location: []*profile.Location{FooLocation},
    74  			},
    75  			{
    76  				Value:    []int64{3},
    77  				Location: []*profile.Location{BarLocation},
    78  			},
    79  		},
    80  		TimeNanos:     1,
    81  		DurationNanos: int64(15 * time.Nanosecond),
    82  		Mapping:       []*profile.Mapping{FooMapping},
    83  		Location:      []*profile.Location{FooLocation, BarLocation},
    84  		Function:      []*profile.Function{FooFunction, BarFunction},
    85  		PeriodType: &profile.ValueType{
    86  			Type: "cpu",
    87  			Unit: "nanoseconds",
    88  		},
    89  		Period: 10000000,
    90  	}
    91  
    92  	FooBarProfileWithSpans = &profile.Profile{
    93  		SampleType: []*profile.ValueType{
    94  			{Type: "cpu", Unit: "nanoseconds"},
    95  		},
    96  		DefaultSampleType: "cpu",
    97  		Sample: []*profile.Sample{
    98  			{
    99  				Value:    []int64{1},
   100  				Location: []*profile.Location{FooLocation, BarLocation},
   101  				Label: map[string][]string{
   102  					"span_id": {"badbadbadbadbada"},
   103  				},
   104  			},
   105  			{
   106  				Value:    []int64{1},
   107  				Location: []*profile.Location{FooLocation, BarLocation},
   108  				Label: map[string][]string{
   109  					"span_id": {"badbadbadbadbadb"},
   110  				},
   111  			},
   112  			{
   113  				Value:    []int64{2},
   114  				Location: []*profile.Location{FooLocation},
   115  				Label: map[string][]string{
   116  					"span_id": {"badbadbadbadbadb"},
   117  				},
   118  			},
   119  			{
   120  				Value:    []int64{3},
   121  				Location: []*profile.Location{BarLocation},
   122  			},
   123  		},
   124  		TimeNanos:     1,
   125  		DurationNanos: int64(15 * time.Nanosecond),
   126  		Mapping:       []*profile.Mapping{FooMapping},
   127  		Location:      []*profile.Location{FooLocation, BarLocation},
   128  		Function:      []*profile.Function{FooFunction, BarFunction},
   129  		PeriodType: &profile.ValueType{
   130  			Type: "cpu",
   131  			Unit: "nanoseconds",
   132  		},
   133  		Period: 10000000,
   134  	}
   135  )