void mozilla_sampler_save_profile_to_file(const char* aFilename) { GeckoSampler *t = tlsTicker.get(); if (!t) { return; } std::ofstream stream; stream.open(aFilename); if (stream.is_open()) { t->ToStreamAsJSON(stream); stream.close(); LOGF("Saved to %s", aFilename); } else { LOG("Fail to open profile log file."); } }
void mozilla_sampler_shutdown() { sInitCount--; if (sInitCount > 0) return; // Save the profile on shutdown if requested. GeckoSampler *t = tlsTicker.get(); if (t) { const char *val = getenv("MOZ_PROFILER_SHUTDOWN"); if (val) { std::ofstream stream; stream.open(val); if (stream.is_open()) { t->ToStreamAsJSON(stream); stream.close(); } } } profiler_stop(); #ifndef SPS_STANDALONE set_stderr_callback(nullptr); #endif Sampler::Shutdown(); #ifdef SPS_STANDALONE mozilla::TimeStamp::Shutdown(); #endif PseudoStack *stack = tlsPseudoStack.get(); stack->deref(); tlsPseudoStack.set(nullptr); #ifdef MOZ_TASK_TRACER mozilla::tasktracer::ShutdownTaskTracer(); #endif }