File: pprof_test.go

package info (click to toggle)
golang-github-felixge-fgprof 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 512 kB
  • sloc: makefile: 5
file content (36 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package fgprof

import (
	"strings"
	"testing"
)

func Test_toProfile(t *testing.T) {
	s := map[string]int{
		"foo;bar": 2,
		"foo":     1,
	}

	p := toProfile(s, 99)
	if err := p.CheckValid(); err != nil {
		t.Fatal(err)
	}

	want := strings.TrimSpace(`
Period: 0
Samples:
samples/count time/nanoseconds
          1   10101010: 1 
          2   20202020: 2 3 
Locations
     1: 0x0 M=1 foo :0 s=0()
     2: 0x0 M=1 foo :0 s=0()
     3: 0x0 M=1 bar :0 s=0()
Mappings
1: 0x0/0x0/0x0   [FN]
`)
	got := strings.TrimSpace(p.String())
	if want != got {
		t.Fatalf("got:\n%s\n\nwant:\n%s", got, want)
	}
}