diff --git a/README.md b/README.md index 653548d..e7dc8f8 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ modification. Todo ---- +* More unit testing * Code cleanup * Better code documentation * Markdown pretty-printer output engine diff --git a/example/main.go b/example/main.go index 4482fd8..8250a44 100644 --- a/example/main.go +++ b/example/main.go @@ -18,12 +18,13 @@ import ( "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 @@ func main() { "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() { @@ -53,6 +56,16 @@ func main() { 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 var input []byte var err os.Error