예제 #1
0
void V8ProfilerAgentImpl::consoleProfileEnd(const String& title)
{
    ASSERT(m_frontend && m_enabled);
    String id;
    String resolvedTitle;
    // Take last started profile if no title was passed.
    if (title.isNull()) {
        if (m_startedProfiles.isEmpty())
            return;
        id = m_startedProfiles.last().m_id;
        resolvedTitle = m_startedProfiles.last().m_title;
        m_startedProfiles.removeLast();
    } else {
        for (size_t i = 0; i < m_startedProfiles.size(); i++) {
            if (m_startedProfiles[i].m_title == title) {
                resolvedTitle = title;
                id = m_startedProfiles[i].m_id;
                m_startedProfiles.remove(i);
                break;
            }
        }
        if (id.isEmpty())
            return;
    }
    RefPtr<TypeBuilder::Profiler::CPUProfile> profile = stopProfiling(id, true);
    if (!profile)
        return;
    RefPtr<TypeBuilder::Debugger::Location> location = currentDebugLocation();
    m_frontend->consoleProfileFinished(id, location, profile, resolvedTitle.isNull() ? 0 : &resolvedTitle);
}
예제 #2
0
RefPtr<JSC::Profile> InspectorTimelineAgent::stopFromConsole(JSC::ExecState* exec, const String& title)
{
    // Stop profiles in reverse order. If the title is empty, then stop the last profile.
    // Otherwise, match the title of the profile to stop.
    for (ptrdiff_t i = m_pendingConsoleProfileRecords.size() - 1; i >= 0; --i) {
        const TimelineRecordEntry& record = m_pendingConsoleProfileRecords[i];

        String recordTitle;
        record.data->getString(ASCIILiteral("title"), recordTitle);

        if (title.isEmpty() || recordTitle == title) {
            RefPtr<JSC::Profile> profile = stopProfiling(exec, title);
            if (profile)
                TimelineRecordFactory::appendProfile(record.data.get(), profile.copyRef());

            didCompleteRecordEntry(record);

            m_pendingConsoleProfileRecords.remove(i);

            if (!m_enabledFromFrontend && m_pendingConsoleProfileRecords.isEmpty())
                internalStop();

            return WTF::move(profile);
        }
    }

    return nullptr;
}
예제 #3
0
void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
{
    if (!m_enabled)
        return;
    String16 id;
    String16 resolvedTitle;
    // Take last started profile if no title was passed.
    if (title.isEmpty()) {
        if (m_startedProfiles.empty())
            return;
        id = m_startedProfiles.back().m_id;
        resolvedTitle = m_startedProfiles.back().m_title;
        m_startedProfiles.pop_back();
    } else {
        for (size_t i = 0; i < m_startedProfiles.size(); i++) {
            if (m_startedProfiles[i].m_title == title) {
                resolvedTitle = title;
                id = m_startedProfiles[i].m_id;
                m_startedProfiles.erase(m_startedProfiles.begin() + i);
                break;
            }
        }
        if (id.isEmpty())
            return;
    }
    std::unique_ptr<protocol::Profiler::CPUProfile> profile = stopProfiling(id, true);
    if (!profile)
        return;
    std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocation(m_session->debugger());
    m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile), resolvedTitle);
}
QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine) :
    QQmlAbstractProfilerAdapter(service)
{
    engine->enableProfiler();
    connect(this, SIGNAL(profilingEnabled()), engine->profiler, SLOT(startProfiling()));
    connect(this, SIGNAL(profilingEnabledWhileWaiting()),
            engine->profiler, SLOT(startProfiling()), Qt::DirectConnection);
    connect(this, SIGNAL(profilingDisabled()), engine->profiler, SLOT(stopProfiling()));
    connect(this, SIGNAL(profilingDisabledWhileWaiting()),
            engine->profiler, SLOT(stopProfiling()), Qt::DirectConnection);
    connect(this, SIGNAL(dataRequested()), engine->profiler, SLOT(reportData()));
    connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)),
            engine->profiler, SLOT(setTimer(QElapsedTimer)));
    connect(engine->profiler, SIGNAL(dataReady(QList<QQmlProfilerData>)),
            this, SLOT(receiveData(QList<QQmlProfilerData>)));
}
예제 #5
0
파일: mal.c 프로젝트: jaiminpan/Monetdb
void mal_exit(void){
	str err;

	/*
	 * Before continuing we should make sure that all clients
	 * (except the console) have left the scene.
	 */
	MCstopClients(0);
#if 0
{
	int reruns=0, go_on;
	do{
		if ( (go_on = MCactiveClients()) )
			MT_sleep_ms(1000);
		mnstr_printf(mal_clients->fdout,"#MALexit: %d clients still active\n", go_on);
	} while (++reruns < SERVERSHUTDOWNDELAY && go_on > 1);
}
#endif
	stopHeartbeat();
#ifdef HAVE_JSONSTORE
	stopHttpdaemon();
#endif
	stopMALdataflow();
	stopProfiling();
	RECYCLEdrop(mal_clients); /* remove any left over intermediates */
	unloadLibraries();
#if 0
	/* skip this to solve random crashes, needs work */
	freeModuleList(mal_clients->nspace);

	finishNamespace();
	if( mal_clients->prompt)
		GDKfree(mal_clients->prompt);
	if( mal_clients->errbuf)
		GDKfree(mal_clients->errbuf);
	if( mal_clients->bak)
		GDKfree(mal_clients->bak);
	if( mal_clients->fdin){
		/* missing protection against closing stdin stream */
		(void) mnstr_close(mal_clients->fdin->s);
		(void) bstream_destroy(mal_clients->fdin);
	}
	if( mal_clients->fdout && mal_clients->fdout != GDKstdout) {
		(void) mnstr_close(mal_clients->fdout);
		(void) mnstr_destroy(mal_clients->fdout);
	}
#endif
	/* deregister everything that was registered, ignore errors */
	if ((err = msab_wildRetreat()) != NULL) {
		fprintf(stderr, "!%s", err);
		free(err);
	}
	/* the server will now be shut down */
	if ((err = msab_registerStop()) != NULL) {
		fprintf(stderr, "!%s", err);
		free(err);
	}
	GDKexit(0); 	/* properly end GDK */
}
예제 #6
0
void V8ProfilerAgentImpl::disable(ErrorString*)
{
    for (Vector<ProfileDescriptor>::reverse_iterator it = m_startedProfiles.rbegin(); it != m_startedProfiles.rend(); ++it)
        stopProfiling(it->m_id, false);
    m_startedProfiles.clear();
    stop(0, 0);
    m_enabled = false;
}
예제 #7
0
void V8ProfilerAgentImpl::disable(ErrorString* errorString)
{
    if (!m_enabled)
        return;
    for (size_t i = m_startedProfiles.size(); i > 0; --i)
        stopProfiling(m_startedProfiles[i - 1].m_id, false);
    m_startedProfiles.clear();
    stop(nullptr, nullptr);
    m_enabled = false;
    m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
}
void InspectorProfilerAgent::stop(ErrorString*)
{
    if (!m_recordingCPUProfile)
        return;
    m_recordingCPUProfile = false;
    String title = getCurrentUserInitiatedProfileName();
    RefPtr<ScriptProfile> profile = stopProfiling(title);
    if (profile)
        addProfile(profile, 0, 0, String());
    toggleRecordButton(false);
}
예제 #9
0
QT_BEGIN_NAMESPACE

QV4ProfilerAdapter::QV4ProfilerAdapter(QQmlProfilerService *service, QV4::ExecutionEngine *engine) :
    QQmlAbstractProfilerAdapter(service)
{
    engine->enableProfiler();
    connect(this, SIGNAL(profilingEnabled(quint64)),
            engine->profiler, SLOT(startProfiling(quint64)));
    connect(this, SIGNAL(profilingEnabledWhileWaiting(quint64)),
            engine->profiler, SLOT(startProfiling(quint64)), Qt::DirectConnection);
    connect(this, SIGNAL(profilingDisabled()), engine->profiler, SLOT(stopProfiling()));
    connect(this, SIGNAL(profilingDisabledWhileWaiting()), engine->profiler, SLOT(stopProfiling()),
            Qt::DirectConnection);
    connect(this, SIGNAL(dataRequested()), engine->profiler, SLOT(reportData()));
    connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)),
            engine->profiler, SLOT(setTimer(QElapsedTimer)));
    connect(engine->profiler, SIGNAL(dataReady(QList<QV4::Profiling::FunctionCallProperties>,
                                               QList<QV4::Profiling::MemoryAllocationProperties>)),
            this, SLOT(receiveData(QList<QV4::Profiling::FunctionCallProperties>,
                                   QList<QV4::Profiling::MemoryAllocationProperties>)));
}
예제 #10
0
void V8ProfilerAgentImpl::disable(ErrorString* errorString)
{
    if (!m_enabled)
        return;
    for (size_t i = m_startedProfiles.size(); i > 0; --i)
        stopProfiling(m_startedProfiles[i - 1].m_id, false);
    m_startedProfiles.clear();
    stop(nullptr, nullptr);
#if ENSURE_V8_VERSION(5, 4)
    m_profiler->Dispose();
    m_profiler = nullptr;
#endif
    m_enabled = false;
    m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
}
예제 #11
0
void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protocol::Profiler::CPUProfile>* profile)
{
    if (!m_recordingCPUProfile) {
        if (errorString)
            *errorString = "No recording profiles found";
        return;
    }
    m_recordingCPUProfile = false;
    std::unique_ptr<protocol::Profiler::CPUProfile> cpuProfile = stopProfiling(m_frontendInitiatedProfileId, !!profile);
    if (profile) {
        *profile = std::move(cpuProfile);
        if (!profile->get() && errorString)
            *errorString = "Profile is not found";
    }
    m_frontendInitiatedProfileId = String16();
    m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
}
PassRefPtr<TypeBuilder::Profiler::ProfileHeader> InspectorProfilerAgent::stop(ErrorString* errorString)
{
    if (!m_recordingCPUProfile)
        return 0;
    m_recordingCPUProfile = false;
    String title = getCurrentUserInitiatedProfileName();
    RefPtr<ScriptProfile> profile = stopProfiling(title);
    RefPtr<TypeBuilder::Profiler::ProfileHeader> profileHeader;
    if (profile) {
        addProfile(profile, 0, String());
        profileHeader = createProfileHeader(*profile);
    } else if (errorString)
        *errorString = "Profile wasn't found";
    toggleRecordButton(false);
    m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
    return profileHeader;
}
예제 #13
0
void V8ProfilerAgentImpl::stop(ErrorString* errorString, RefPtr<TypeBuilder::Profiler::CPUProfile>* profile)
{
    if (!m_recordingCPUProfile) {
        if (errorString)
            *errorString = "No recording profiles found";
        return;
    }
    m_recordingCPUProfile = false;
    RefPtr<TypeBuilder::Profiler::CPUProfile> cpuProfile = stopProfiling(m_frontendInitiatedProfileId, !!profile);
    if (profile) {
        *profile = cpuProfile;
        if (!cpuProfile && errorString)
            *errorString = "Profile is not found";
    }
    m_frontendInitiatedProfileId = String();
    m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
}
예제 #14
0
void InspectorTimelineAgent::didEvaluateScript(Frame* frame)
{
    if (frame && m_recordingProfile) {
        if (m_recordStack.isEmpty())
            return;

        TimelineRecordEntry& entry = m_recordStack.last();
        ASSERT(entry.type == TimelineRecordType::EvaluateScript);

        RefPtr<JSC::Profile> profile = stopProfiling(frame, ASCIILiteral("Timeline EvaluateScript"));
        if (profile)
            TimelineRecordFactory::appendProfile(entry.data.get(), profile.release());

        m_recordingProfile = false;
    }

    didCompleteCurrentRecord(TimelineRecordType::EvaluateScript);
}
void InspectorTimelineAgent::stop(ErrorString&) {
    if (!m_enabled)
        return;

    RefPtr<JSC::Profile> profile = stopProfiling(m_globalObject.globalExec(), WTF::emptyString());
    if (profile)
        TimelineRecordFactory::appendProfile(m_consoleRecordEntry.data.get(), profile.copyRef());

    didCompleteRecordEntry(m_consoleRecordEntry);

    auto stopwatch = m_globalObject.inspectorController().executionStopwatch();
    if (stopwatch->isActive())
        stopwatch->stop();

    m_enabled = false;

    if (m_frontendDispatcher)
        m_frontendDispatcher->recordingStopped(timestamp());
}
예제 #16
0
void InspectorTimelineAgent::didCallFunction(Frame* frame)
{
    if (frame && m_callStackDepth) {
        --m_callStackDepth;
        ASSERT(m_callStackDepth >= 0);

        if (!m_callStackDepth) {
            if (m_recordStack.isEmpty())
                return;

            TimelineRecordEntry& entry = m_recordStack.last();
            ASSERT(entry.type == TimelineRecordType::FunctionCall);

            RefPtr<JSC::Profile> profile = stopProfiling(frame, ASCIILiteral("Timeline FunctionCall"));
            if (profile)
                TimelineRecordFactory::appendProfile(entry.data.get(), profile.release());
        }
    }

    didCompleteCurrentRecord(TimelineRecordType::FunctionCall);
}
예제 #17
0
static inline PassRefPtr<JSC::Profile> stopProfiling(Frame* frame, const String& title)
{
    return stopProfiling(toJSDOMWindow(frame, debuggerWorld())->globalExec(), title);
}
예제 #18
0
void AbstractAI::check()
{
#if defined(AIDEBUG)
	AbstractAction* oldaction = m_currentAction;
#endif

	startProfiling( PF_AICHECKFINDACTION );
	// If we have no current action or our action cant be executed, we must get a new one
	if ( !m_currentAction || ( m_currentAction && m_currentAction->preCondition() <= 0.0f ) )
	{
		std::vector<stActionNode> actions;
		std::vector<stActionNode>::iterator it;

		AbstractAction* action = NULL;
		for ( action = m_actions.first(); action; action = m_actions.next() )
		{
			actions.push_back( stActionNode( action->preCondition(), action ) );
		}
		std::sort( actions.begin(), actions.end(), ActionNodeComparePredicate() );

		it = actions.begin();
		while ( it != actions.end() && !m_currentAction )
		{
			if ( ( *it ).fuzzy > 0.0f )
				m_currentAction = ( *it ).action;
			++it;
		}
	}
	stopProfiling( PF_AICHECKFINDACTION );

	// Action is changing
#if defined(AIDEBUG)
	if ( m_currentAction && oldaction != m_currentAction )
	{
		QString message = QString( "[NEWACTION: %1]" ).arg( m_currentAction->name() );
		m_npc->talk( message );
	}
#endif

	m_npc->setAICheckTime( Server::instance()->time() + m_npc->wanderSpeed() );

	// Now we should have a current action set, else do nothing!
	startProfiling( PF_AICHECKEXECUTEACTION );
	if ( m_currentAction )
	{
		if ( !m_currentAction->isPassive() )
		{
			m_npc->setAICheckTime( Server::instance()->time() + m_npc->actionSpeed() );
		}

		m_currentAction->execute();

		// We must check the postcondition now and set the current action to NULL
		// if the action is finished (when it returns >= 1.0f)!
		float rnd = RandomNum( 0, 1000 ) / 1000.0f;
		if ( m_currentAction->postCondition() >= rnd )
		{
			// Action changing
#if defined(AIDEBUG)
			QString message = QString( "[ENDACTION: %1]" ).arg( m_currentAction->name() );
			m_npc->talk( message );
#endif

			m_currentAction = NULL;
		}
	}

	stopProfiling( PF_AICHECKEXECUTEACTION );
}