| 72 | } |
| 73 | |
| 74 | int MakeProfName(ProfilingType type, char* buf, size_t buf_len) { |
| 75 | // Add pprof_ prefix to separate from /hotspots |
| 76 | int nr = snprintf(buf, buf_len, "%s/pprof_%s/", FLAGS_rpc_profiling_dir.c_str(), |
| 77 | GetProgramChecksum()); |
| 78 | if (nr < 0) { |
| 79 | return -1; |
| 80 | } |
| 81 | buf += nr; |
| 82 | buf_len -= nr; |
| 83 | |
| 84 | time_t rawtime; |
| 85 | time(&rawtime); |
| 86 | struct tm* timeinfo = localtime(&rawtime); |
| 87 | const size_t nw = strftime(buf, buf_len, "%Y%m%d.%H%M%S", timeinfo); |
| 88 | buf += nw; |
| 89 | buf_len -= nw; |
| 90 | |
| 91 | // We have checksum in the path, getpid() is not necessary now. |
| 92 | snprintf(buf, buf_len, ".%s", ProfilingType2String(type)); |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | void PProfService::profile( |
| 97 | ::google::protobuf::RpcController* controller_base, |
no test coverage detected