本文整理汇总了C++中TableTicker类的典型用法代码示例。如果您正苦于以下问题:C++ TableTicker类的具体用法?C++ TableTicker怎么用?C++ TableTicker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TableTicker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
NS_IMETHOD Run() {
TableTicker *t = mozilla::tls::get<TableTicker>(pkey_ticker);
char buff[MAXPATHLEN];
#ifdef ANDROID
#define FOLDER "/sdcard/"
#elif defined(XP_WIN)
#define FOLDER "%TEMP%\\"
#else
#define FOLDER "/tmp/"
#endif
snprintf(buff, MAXPATHLEN, "%sprofile_%i_%i.txt", FOLDER, XRE_GetProcessType(), getpid());
#ifdef XP_WIN
// Expand %TEMP% on Windows
{
char tmp[MAXPATHLEN];
ExpandEnvironmentStringsA(buff, tmp, mozilla::ArrayLength(tmp));
strcpy(buff, tmp);
}
#endif
FILE* stream = ::fopen(buff, "w");
if (stream) {
t->GetProfile()->WriteProfile(stream);
::fclose(stream);
LOG("Saved to " FOLDER "profile_TYPE_PID.txt");
} else {
LOG("Fail to open profile log file.");
}
return NS_OK;
}
示例2: mozilla_sampler_shutdown
void mozilla_sampler_shutdown()
{
sInitCount--;
if (sInitCount > 0)
return;
// Save the profile on shutdown if requested.
TableTicker *t = tlsTicker.get();
if (t) {
const char *val = PR_GetEnv("MOZ_PROFILER_SHUTDOWN");
if (val) {
std::ofstream stream;
stream.open(val);
if (stream.is_open()) {
t->ToStreamAsJSON(stream);
stream.close();
}
}
}
profiler_stop();
set_stderr_callback(nullptr);
Sampler::Shutdown();
PseudoStack *stack = tlsPseudoStack.get();
stack->deref();
tlsPseudoStack.set(nullptr);
}
示例3: mozilla_sampler_start
// Values are only honored on the first start
void mozilla_sampler_start(int aProfileEntries, int aInterval,
const char** aFeatures, uint32_t aFeatureCount)
{
if (!stack_key_initialized)
mozilla_sampler_init();
ProfileStack *stack = tlsStack.get();
if (!stack) {
ASSERT(false);
return;
}
mozilla_sampler_stop();
TableTicker *t = new TableTicker(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL,
aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY,
stack, aFeatures, aFeatureCount);
tlsTicker.set(t);
t->Start();
if (t->ProfileJS())
stack->enableJSSampling();
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os)
os->NotifyObservers(nullptr, "profiler-started", nullptr);
}
示例4: mozilla_sampler_shutdown
void mozilla_sampler_shutdown()
{
sInitCount--;
if (sInitCount > 0)
return;
// Save the profile on shutdown if requested.
TableTicker *t = tlsTicker.get();
if (t) {
const char *val = PR_GetEnv("MOZ_PROFILER_SHUTDOWN");
if (val) {
std::ofstream stream;
stream.open(val);
if (stream.is_open()) {
t->ToStreamAsJSON(stream);
stream.close();
}
}
}
profiler_stop();
set_stderr_callback(nullptr);
Sampler::Shutdown();
// We can't delete the Stack because we can be between a
// sampler call_enter/call_exit point.
// TODO Need to find a safe time to delete Stack
}
示例5: MOZ_ASSERT
void PseudoStack::flushSamplerOnJSShutdown()
{
MOZ_ASSERT(mRuntime);
TableTicker* t = tlsTicker.get();
if (t) {
t->FlushOnJSShutdown(mRuntime);
}
}
示例6: mozilla_sampler_is_active
bool mozilla_sampler_is_active()
{
TableTicker *t = mozilla::tls::get<TableTicker>(pkey_ticker);
if (!t) {
return false;
}
return t->IsActive();
}
示例7:
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, float aSinceTime)
{
TableTicker *t = Sampler::GetActiveSampler();
if (!t) {
return nullptr;
}
return t->ToJSObject(aCx, aSinceTime);
}
示例8: mozilla_sampler_get_profile
mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(float aSinceTime)
{
TableTicker *t = Sampler::GetActiveSampler();
if (!t) {
return nullptr;
}
return t->ToJSON(aSinceTime);
}
示例9:
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx)
{
TableTicker *t = tlsTicker.get();
if (!t) {
return nullptr;
}
return t->ToJSObject(aCx);
}
示例10: mozilla_sampler_stop
void mozilla_sampler_stop()
{
TableTicker *t = mozilla::tls::get<TableTicker>(pkey_ticker);
if (!t) {
return;
}
t->Stop();
mozilla::tls::set(pkey_ticker, (Stack*)NULL);
}
示例11: mozilla_sampler_save
void mozilla_sampler_save() {
TableTicker *t = mozilla::tls::get<TableTicker>(pkey_ticker);
if (!t) {
return;
}
t->RequestSave();
// We're on the main thread already so we don't
// have to wait to handle the save request.
t->HandleSaveRequest();
}
示例12: mozilla_sampler_get_profile
char* mozilla_sampler_get_profile()
{
TableTicker *t = tlsTicker.get();
if (!t) {
return nullptr;
}
std::stringstream stream;
t->ToStreamAsJSON(stream);
char* profile = strdup(stream.str().c_str());
return profile;
}
示例13: mozilla_sampler_is_active
bool mozilla_sampler_is_active()
{
if (!stack_key_initialized)
mozilla_sampler_init();
TableTicker *t = tlsTicker.get();
if (!t) {
return false;
}
return t->IsActive();
}
示例14: mozilla_sampler_stop
void mozilla_sampler_stop()
{
LOG("BEGIN mozilla_sampler_stop");
if (!stack_key_initialized)
profiler_init(nullptr);
TableTicker *t = tlsTicker.get();
if (!t) {
LOG("END mozilla_sampler_stop-early");
return;
}
bool disableJS = t->ProfileJS();
bool unwinderThreader = t->HasUnwinderThread();
// Shut down and reap the unwinder thread. We have to do this
// before stopping the sampler, so as to guarantee that the unwinder
// thread doesn't try to access memory that the subsequent call to
// mozilla_sampler_stop causes to be freed.
if (unwinderThreader) {
uwt__stop();
}
t->Stop();
delete t;
tlsTicker.set(nullptr);
if (disableJS) {
PseudoStack *stack = tlsPseudoStack.get();
ASSERT(stack != nullptr);
stack->disableJSSampling();
}
if (unwinderThreader) {
uwt__deinit();
}
mozilla::IOInterposer::Unregister(mozilla::IOInterposeObserver::OpAll,
sInterposeObserver);
sInterposeObserver = nullptr;
sIsProfiling = false;
if (Sampler::CanNotifyObservers()) {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os)
os->NotifyObservers(nullptr, "profiler-stopped", nullptr);
}
LOG("END mozilla_sampler_stop");
}
示例15: mozilla_sampler_get_profile
char* mozilla_sampler_get_profile() {
TableTicker *t = mozilla::tls::get<TableTicker>(pkey_ticker);
if (!t) {
return NULL;
}
string profile;
t->GetProfile()->ToString(&profile);
char *rtn = (char*)malloc( (strlen(profile.c_str())+1) * sizeof(char) );
strcpy(rtn, profile.c_str());
return rtn;
}