all repos — grayfriday @ a74678bf51d2cdcdeb81e3dae3ec5a6eb13cd432

blackfriday fork with a few changes

enable profiling from command-line tool
Russ Ross russ@russross.com
Fri, 24 Jun 2011 17:13:42 -0600
commit

a74678bf51d2cdcdeb81e3dae3ec5a6eb13cd432

parent

c337e07e74a5363e38439f99ca3324324b9377ae

2 files changed, 15 insertions(+), 1 deletions(-)

jump to
M README.mdREADME.md

@@ -92,6 +92,7 @@

Todo ---- +* More unit testing * Code cleanup * Better code documentation * Markdown pretty-printer output engine
M example/main.goexample/main.go

@@ -18,12 +18,13 @@ "fmt"

"io/ioutil" "github.com/russross/blackfriday" "os" + "runtime/pprof" ) func main() { // parse command-line options var page, xhtml, latex, smartypants bool - var css string + var css, cpuprofile string var repeat int flag.BoolVar(&page, "page", false, "Generate a standalone HTML page (implies -latex=false)")

@@ -35,6 +36,8 @@ flag.BoolVar(&smartypants, "smartypants", false,

"Apply smartypants-style substitutions") flag.StringVar(&css, "css", "", "Link to a CSS stylesheet (implies -page)") + flag.StringVar(&cpuprofile, "cpuprofile", "", + "Write cpu profile to a file") flag.IntVar(&repeat, "repeat", 1, "Process the input multiple times (for benchmarking)") flag.Usage = func() {

@@ -51,6 +54,16 @@ page = true

} if page { latex = false + } + + // turn on profiling? + if cpuprofile != "" { + f, err := os.Create(cpuprofile) + if err != nil { + fmt.Fprintln(os.Stderr, err) + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() } // read the input