Commit 0b8c983e authored by Russ Cox's avatar Russ Cox

runtime/pprof/internal/profile: move internal/pprof/profile here

Nothing needs internal/pprof anymore except the runtime/pprof tests.
Move the package here to prevent new dependencies.

Change-Id: Ia119af91cc2b980e0fa03a15f46f69d7f71d2926
Reviewed-on: https://go-review.googlesource.com/37165
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarMichael Matloob <matloob@golang.org>
parent cbab65fd
...@@ -9,13 +9,14 @@ package main ...@@ -9,13 +9,14 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"internal/pprof/profile"
"internal/trace" "internal/trace"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"github.com/google/pprof/profile"
) )
func init() { func init() {
......
...@@ -221,53 +221,53 @@ var pkgDeps = map[string][]string{ ...@@ -221,53 +221,53 @@ var pkgDeps = map[string][]string{
"go/types": {"L4", "GOPARSER", "container/heap", "go/constant"}, "go/types": {"L4", "GOPARSER", "container/heap", "go/constant"},
// One of a kind. // One of a kind.
"archive/tar": {"L4", "OS", "syscall"}, "archive/tar": {"L4", "OS", "syscall"},
"archive/zip": {"L4", "OS", "compress/flate"}, "archive/zip": {"L4", "OS", "compress/flate"},
"container/heap": {"sort"}, "container/heap": {"sort"},
"compress/bzip2": {"L4"}, "compress/bzip2": {"L4"},
"compress/flate": {"L4"}, "compress/flate": {"L4"},
"compress/gzip": {"L4", "compress/flate"}, "compress/gzip": {"L4", "compress/flate"},
"compress/lzw": {"L4"}, "compress/lzw": {"L4"},
"compress/zlib": {"L4", "compress/flate"}, "compress/zlib": {"L4", "compress/flate"},
"context": {"errors", "fmt", "reflect", "sync", "time"}, "context": {"errors", "fmt", "reflect", "sync", "time"},
"database/sql": {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"}, "database/sql": {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"},
"database/sql/driver": {"L4", "context", "time", "database/sql/internal"}, "database/sql/driver": {"L4", "context", "time", "database/sql/internal"},
"debug/dwarf": {"L4"}, "debug/dwarf": {"L4"},
"debug/elf": {"L4", "OS", "debug/dwarf", "compress/zlib"}, "debug/elf": {"L4", "OS", "debug/dwarf", "compress/zlib"},
"debug/gosym": {"L4"}, "debug/gosym": {"L4"},
"debug/macho": {"L4", "OS", "debug/dwarf"}, "debug/macho": {"L4", "OS", "debug/dwarf"},
"debug/pe": {"L4", "OS", "debug/dwarf"}, "debug/pe": {"L4", "OS", "debug/dwarf"},
"debug/plan9obj": {"L4", "OS"}, "debug/plan9obj": {"L4", "OS"},
"encoding": {"L4"}, "encoding": {"L4"},
"encoding/ascii85": {"L4"}, "encoding/ascii85": {"L4"},
"encoding/asn1": {"L4", "math/big"}, "encoding/asn1": {"L4", "math/big"},
"encoding/csv": {"L4"}, "encoding/csv": {"L4"},
"encoding/gob": {"L4", "OS", "encoding"}, "encoding/gob": {"L4", "OS", "encoding"},
"encoding/hex": {"L4"}, "encoding/hex": {"L4"},
"encoding/json": {"L4", "encoding"}, "encoding/json": {"L4", "encoding"},
"encoding/pem": {"L4"}, "encoding/pem": {"L4"},
"encoding/xml": {"L4", "encoding"}, "encoding/xml": {"L4", "encoding"},
"flag": {"L4", "OS"}, "flag": {"L4", "OS"},
"go/build": {"L4", "OS", "GOPARSER"}, "go/build": {"L4", "OS", "GOPARSER"},
"html": {"L4"}, "html": {"L4"},
"image/draw": {"L4", "image/internal/imageutil"}, "image/draw": {"L4", "image/internal/imageutil"},
"image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"}, "image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"},
"image/internal/imageutil": {"L4"}, "image/internal/imageutil": {"L4"},
"image/jpeg": {"L4", "image/internal/imageutil"}, "image/jpeg": {"L4", "image/internal/imageutil"},
"image/png": {"L4", "compress/zlib"}, "image/png": {"L4", "compress/zlib"},
"index/suffixarray": {"L4", "regexp"}, "index/suffixarray": {"L4", "regexp"},
"internal/singleflight": {"sync"}, "internal/singleflight": {"sync"},
"internal/trace": {"L4", "OS"}, "internal/trace": {"L4", "OS"},
"internal/pprof/profile": {"L4", "OS", "compress/gzip", "regexp"}, "math/big": {"L4", "math/bits"},
"math/big": {"L4", "math/bits"}, "mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
"mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"}, "mime/quotedprintable": {"L4"},
"mime/quotedprintable": {"L4"}, "net/internal/socktest": {"L4", "OS", "syscall"},
"net/internal/socktest": {"L4", "OS", "syscall"}, "net/url": {"L4"},
"net/url": {"L4"}, "plugin": {"L0", "OS", "CGO"},
"plugin": {"L0", "OS", "CGO"}, "runtime/pprof/internal/profile": {"L4", "OS", "compress/gzip", "regexp"},
"testing/internal/testdeps": {"L4", "runtime/pprof", "regexp"}, "testing/internal/testdeps": {"L4", "runtime/pprof", "regexp"},
"text/scanner": {"L4", "OS"}, "text/scanner": {"L4", "OS"},
"text/template/parse": {"L4"}, "text/template/parse": {"L4"},
"html/template": { "html/template": {
"L4", "OS", "encoding/json", "html", "text/template", "L4", "OS", "encoding/json", "html", "text/template",
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
// Package profile provides a representation of profile.proto and // Package profile provides a representation of profile.proto and
// methods to encode/decode profiles in this format. // methods to encode/decode profiles in this format.
//
// This package is only for testing runtime/pprof.
// It is not used by production Go programs.
package profile package profile
import ( import (
......
...@@ -9,13 +9,13 @@ package pprof ...@@ -9,13 +9,13 @@ package pprof
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"internal/pprof/profile"
"internal/testenv" "internal/testenv"
"math/big" "math/big"
"os" "os"
"os/exec" "os/exec"
"regexp" "regexp"
"runtime" "runtime"
"runtime/pprof/internal/profile"
"strings" "strings"
"sync" "sync"
"testing" "testing"
......
...@@ -7,10 +7,10 @@ package pprof ...@@ -7,10 +7,10 @@ package pprof
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"internal/pprof/profile"
"io/ioutil" "io/ioutil"
"reflect" "reflect"
"runtime" "runtime"
"runtime/pprof/internal/profile"
"testing" "testing"
) )
......
...@@ -6,8 +6,8 @@ package pprof ...@@ -6,8 +6,8 @@ package pprof
import ( import (
"bytes" "bytes"
"internal/pprof/profile"
"runtime" "runtime"
"runtime/pprof/internal/profile"
"testing" "testing"
) )
......
...@@ -10,7 +10,10 @@ package main ...@@ -10,7 +10,10 @@ package main
import ( import (
"fmt" "fmt"
"log"
"os"
"runtime" "runtime"
"runtime/pprof"
"sync" "sync"
"time" "time"
) )
...@@ -64,6 +67,13 @@ func checkLinear(typ string, tries int, f func(n int)) { ...@@ -64,6 +67,13 @@ func checkLinear(typ string, tries int, f func(n int)) {
const offset = 251 // known size of runtime hash table const offset = 251 // known size of runtime hash table
func main() { func main() {
f, err := os.Create("lock.prof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
checkLinear("lockone", 1000, func(n int) { checkLinear("lockone", 1000, func(n int) {
ch := make(chan int) ch := make(chan int)
locks := make([]sync.RWMutex, offset+1) locks := make([]sync.RWMutex, offset+1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment