# package pprof
`import "net/http/pprof"`
pprof包通过它的HTTP服务端提供pprof可视化工具期望格式的运行时剖面文件数据服务。关于pprof的更多信息,参见[http://code.google.com/p/google-perftools/](http://code.google.com/p/google-perftools/)。
本包一般只需导入获取其注册HTTP处理器的副作用。处理器的路径以/debug/pprof/开始。
要使用pprof,在你的程序里导入本包:
```
import _ "net/http/pprof"
```
如果你的应用还没有运行http服务器,你需要开始一个http服务器。添加"net/http"包和"log"包到你的导入列表,然后在main函数开始处添加如下代码:
```
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
```
然后使用pprof工具查看堆剖面:
```
go tool pprof http://localhost:6060/debug/pprof/heap
```
或查看周期30秒的CPU剖面:
```
go tool pprof http://localhost:6060/debug/pprof/profile
```
或查看go程阻塞剖面:
```
go tool pprof http://localhost:6060/debug/pprof/block
```
要查看所有可用的剖面,在你的浏览器阅读[http://localhost:6060/debug/pprof/](http://localhost:6060/debug/pprof/)。要学习这些运转的设施,访问:
```
http://blog.golang.org/2011/06/profiling-go-programs.html
```
## Index
* [func Handler(name string) http.Handler](#Handler)
* [func Cmdline(w http.ResponseWriter, r \*http.Request)](#Cmdline)
* [func Index(w http.ResponseWriter, r \*http.Request)](#Index)
* [func Profile(w http.ResponseWriter, r \*http.Request)](#Profile)
* [func Symbol(w http.ResponseWriter, r \*http.Request)](#Symbol)
## func [Handler](http://code.google.com/p/go/source/browse/src/pkg/net/http/pprof/pprof.go?name=release#150 "View Source")
```
func Handler(name string) http.Handler
```
Handler返回一个提供name指定的剖面文件的服务的HTTP处理器。
## func [Cmdline](http://code.google.com/p/go/source/browse/src/pkg/net/http/pprof/pprof.go?name=release#72 "View Source")
```
func Cmdline(w http.ResponseWriter, r *http.Request)
```
Cmdline回应执行中程序的命令行,采用NUL字节分隔的参数。本包将它注册在/debug/pprof/cmdline。
## func [Index](http://code.google.com/p/go/source/browse/src/pkg/net/http/pprof/pprof.go?name=release#173 "View Source")
```
func Index(w http.ResponseWriter, r *http.Request)
```
Index回复请求要求的pprof格式的剖面。例如,"/debug/pprof/heap"会回复"heap"剖面。Index会回复"/debug/pprof/" 请求一个列出所有可用的剖面的HTML页面。
## func [Profile](http://code.google.com/p/go/source/browse/src/pkg/net/http/pprof/pprof.go?name=release#79 "View Source")
```
func Profile(w http.ResponseWriter, r *http.Request)
```
Profile回复pprof格式的CPU剖面。本包将它注册在/debug/pprof/profile。
## func [Symbol](http://code.google.com/p/go/source/browse/src/pkg/net/http/pprof/pprof.go?name=release#104 "View Source")
```
func Symbol(w http.ResponseWriter, r *http.Request)
```
Symbol查看请求中列出的程序计数器,回复一个映射程序计数器到函数名的表格。本包将它注册在/debug/pprof/symbol。
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe