Profiling Go Programs
slideshare.net
slideshare.net
http.Handle("/debug/pprof/", http.HandlerFunc(Index))
http.Handle("/debug/pprof/cmdline", http.HandlerFunc(Cmdline))
http.Handle("/debug/pprof/profile", http.HandlerFunc(Profile))
http.Handle("/debug/pprof/symbol", http.HandlerFunc(Symbol))
In my particular case, I wanted all normal application traffic to be handled by my 8080 handler, and the /debug/* traffic handled by another listener on port 6060. Even if I explicitly link the above handler functions into my port 6060 ServeMux, because of the init() method it still registers across all of my handlers. I.e. port 8080 and 6060 both respond to, for example, /debug/pprof/cmdline.I just wonder if it could be more beneficial to the community if Google invested in an IDE with a GUI for all of these tools.
Go uses RE2, not PCRE (which Perl uses, obviously) for regular expressions: https://code.google.com/p/re2/. There is also a third-party PCRE library for Go somewhere, though the standard library uses RE2.
One of the advantages of RE2 is that it guarantees that the regular expression runs in linear time (in the length of the input), unlike backtracking-engines like PCRE (which are provably undecidable, like the halting problem).
However, aside from not supporting backtraces, it also can be slower on certain kinds of regexes and inputs.
As always, the best (only?) way to know which approach is better is to test (profile) - which, I agree, is a piece of cake in Go.
Incidentally, one of the reasons that PCRE is faster is that it uses a JIT in newer versions.