#include #include #include namespace op59_net { /* don't know what other OS's support profil(). presumably NetBSD and FreeBSD. Cygwin doesn't. On OpenBSD, see profil(2). */ #ifdef __OpenBSD__ struct scoped_profil { scoped_profil( size_t buffer_size0, u_long offset0, u_int scale0); /* starts profil(1) profiling. */ void stop(); /* stops profil(1) profiling. */ void output( const std::string& exe0, const std::string& outfile0); /* calls stop(), and then outputs detailed prof info to `outfile0', using `nm' command to get layout information about the current executable, filename exe0. i.e. pass main()'s argv[0] as exe0. */ ~scoped_profil(); /* calls stop(). */ std::string exe; u_long offset; u_long scale; std::vector< char> buffer; std::string outfile; bool running; }; #else struct scoped_profil { scoped_profil( size_t, u_long, u_int) {} void stop() {} void output( const std::string&, const std::string&) {} ~scoped_profil() {} }; #endif }