MCPcopy Create free account
hub / github.com/apple/foundationdb / startProfiling

Function startProfiling

flow/Profiler.actor.cpp:271–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void startProfiling(INetwork* network,
272 Optional<int> maybePeriod /*= {}*/,
273 Optional<StringRef> maybeOutputFile /*= {}*/) {
274 int period;
275 if (maybePeriod.present()) {
276 period = maybePeriod.get();
277 } else {
278 const char* periodEnv = getenv("FLOW_PROFILER_PERIOD");
279 period = (periodEnv ? atoi(periodEnv) : 2000);
280 }
281 std::string outputFile;
282 if (maybeOutputFile.present()) {
283 outputFile = std::string((const char*)maybeOutputFile.get().begin(), maybeOutputFile.get().size());
284 } else {
285 const char* outfn = getenv("FLOW_PROFILER_OUTPUT");
286 outputFile = (outfn ? outfn : "profile.bin");
287 }
288 outputFile = findAndReplace(
289 findAndReplace(
290 findAndReplace(outputFile, "%ADDRESS%", findAndReplace(network->getLocalAddress().toString(), ":", ".")),
291 "%PID%",
292 format("%d", getpid())),
293 "%TID%",
294 format("%llx", (long long)sys_gettid()));
295
296 if (!Profiler::active_profiler)
297 Profiler::active_profiler = new Profiler(period, outputFile, network);
298}
299
300void stopProfiling() {
301 if (Profiler::active_profiler) {

Callers 2

runMethod · 0.85
updateCpuProfilerFunction · 0.85

Calls 9

findAndReplaceFunction · 0.85
sys_gettidFunction · 0.85
formatFunction · 0.70
getMethod · 0.65
presentMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45
getLocalAddressMethod · 0.45

Tested by

no test coverage detected