예제 #1
0
파일: GetTime.c 프로젝트: NathanHowell/ghc
void getProcessTimes(Time *user, Time *elapsed)
{
    static nat ClockFreq = 0;

    if (ClockFreq == 0) {
#if defined(HAVE_SYSCONF)
	long ticks;
	ticks = sysconf(_SC_CLK_TCK);
	if ( ticks == -1 ) {
	    sysErrorBelch("sysconf");
	    stg_exit(EXIT_FAILURE);
	}
	ClockFreq = ticks;
#elif defined(CLK_TCK)		/* defined by POSIX */
	ClockFreq = CLK_TCK;
#elif defined(HZ)
	ClockFreq = HZ;
#elif defined(CLOCKS_PER_SEC)
	ClockFreq = CLOCKS_PER_SEC;
#else
	errorBelch("can't get clock resolution");
	stg_exit(EXIT_FAILURE);
#endif
    }

    struct tms t;
    clock_t r = times(&t);
    *user = SecondsToTime(t.tms_utime) / ClockFreq;
    *elapsed = SecondsToTime(r) / ClockFreq;
}
예제 #2
0
파일: GetTime.c 프로젝트: NathanHowell/ghc
Time getProcessCPUTime(void)
{
#if !defined(BE_CONSERVATIVE) && defined(HAVE_CLOCK_GETTIME) && defined (_SC_CPUTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) && defined(HAVE_SYSCONF)
    static int checked_sysconf = 0;
    static int sysconf_result = 0;

    if (!checked_sysconf) {
        sysconf_result = sysconf(_SC_CPUTIME);
        checked_sysconf = 1;
    }
    if (sysconf_result != -1) {
        struct timespec ts;
        int res;
        res = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
        if (res == 0) {
            return SecondsToTime(ts.tv_sec) + NSToTime(ts.tv_nsec);
        }
    }
#endif

    // fallback to getrusage
    {
        struct rusage t;
        getrusage(RUSAGE_SELF, &t);
        return SecondsToTime(t.ru_utime.tv_sec) + USToTime(t.ru_utime.tv_usec);
    }
}
예제 #3
0
const WCHAR* MeasureNowPlaying::GetStringValue()
{
	if (!m_Parent) return nullptr;

	const Player* player = m_Parent->player;
	static WCHAR buffer[32];
	const WCHAR* str = nullptr;
	switch (m_Type)
	{
	case MEASURE_ARTIST:
		str = player->GetArtist();
		break;

	case MEASURE_TITLE:
		str = player->GetTitle();
		break;

	case MEASURE_ALBUM:
		str = player->GetAlbum();
		break;

	case MEASURE_LYRICS:
		str = player->GetLyrics();
		break;

	case MEASURE_COVER:
		str = player->GetCoverPath();
		break;

	case MEASURE_FILE:
		str = player->GetFilePath();
		break;

	case MEASURE_DURATION:
		SecondsToTime(player->GetDuration(), m_Parent->disableLeadingZero, buffer);
		str = buffer;
		break;

	case MEASURE_POSITION:
		SecondsToTime(player->GetPosition(), m_Parent->disableLeadingZero, buffer);
		str = buffer;
		break;

	case MEASURE_GENRE:
		str = player->GetGenre();
		break;
	}

	return str ? CheckSubstitute(str) : nullptr;
}
예제 #4
0
파일: GetTime.c 프로젝트: NathanHowell/ghc
Time getThreadCPUTime(void)
{
#if USE_PAPI
    long long usec;
    if ((usec = PAPI_get_virt_usec()) < 0) {
	barf("PAPI_get_virt_usec: %lld", usec);
    }
    return USToTime(usec);

#elif !defined(BE_CONSERVATIVE) && defined(HAVE_CLOCK_GETTIME) && defined (_SC_THREAD_CPUTIME) && defined(CLOCK_THREAD_CPUTIME_ID) && defined(HAVE_SYSCONF)
    {
        static int checked_sysconf = 0;
        static int sysconf_result = 0;
        
        if (!checked_sysconf) {
            sysconf_result = sysconf(_SC_THREAD_CPUTIME);
            checked_sysconf = 1;
        }
        if (sysconf_result != -1) {
            // clock_gettime() gives us per-thread CPU time.  It isn't
            // reliable on Linux, but it's the best we have.
            struct timespec ts;
            int res;
            res = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
            if (res == 0) {
                return SecondsToTime(ts.tv_sec) + NSToTime(ts.tv_nsec);
            }
        }
    }
#endif
    return getProcessCPUTime();
}
예제 #5
0
void CCopyMapUISurvive::StartSurviveSeconds(int nSeconds)
{
	if(!m_pSurviveSeconds || nSeconds<0) return;

	EndSurviveSeconds();

	m_nSurviveSeconds = nSeconds;
	m_pSurviveSeconds->setEnabled(true);
	m_pSurviveSeconds->setText(SecondsToTime(m_nSurviveSeconds,1));
	schedule(schedule_selector(CCopyMapUISurvive::ScheduleSurviveSeconds),1.0f,kRepeatForever,1.0f);
}
예제 #6
0
파일: hschooks.c 프로젝트: Eufavn/ghc
void
defaultsHook (void)
{
    RtsFlags.GcFlags.heapSizeSuggestion = 6*1024*1024 / BLOCK_SIZE;
    RtsFlags.GcFlags.maxStkSize         = 512*1024*1024 / sizeof(W_);
    RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS;

    // See #3408: the default idle GC time of 0.3s is too short on
    // Windows where we receive console events once per second or so.
#if __GLASGOW_HASKELL__ >= 703
    RtsFlags.GcFlags.idleGCDelayTime = SecondsToTime(5);
#else
    RtsFlags.GcFlags.idleGCDelayTime = 5*1000;
#endif
}
예제 #7
0
void
defaultsHook (void)
{
    // This helps particularly with large compiles, but didn't work
    // very well with earlier GHCs because it caused large amounts of
    // fragmentation.  See rts/sm/BlockAlloc.c:allocLargeChunk().
    RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue;

    RtsFlags.GcFlags.maxStkSize         = 512*1024*1024 / sizeof(W_);

    initGCStatistics();

    // See #3408: the default idle GC time of 0.3s is too short on
    // Windows where we receive console events once per second or so.
    RtsFlags.GcFlags.idleGCDelayTime = SecondsToTime(5);
}
예제 #8
0
파일: hschooks.c 프로젝트: A1kmm/ghc
void
defaultsHook (void)
{
#if __GLASGOW_HASKELL__ >= 707
    // This helps particularly with large compiles, but didn't work
    // very well with earlier GHCs because it caused large amounts of
    // fragmentation.  See rts/sm/BlockAlloc.c:allocLargeChunk().
    RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue;
#else
    RtsFlags.GcFlags.heapSizeSuggestion = 6*1024*1024 / BLOCK_SIZE;
#endif

    RtsFlags.GcFlags.maxStkSize         = 512*1024*1024 / sizeof(W_);
    RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS;

    // See #3408: the default idle GC time of 0.3s is too short on
    // Windows where we receive console events once per second or so.
#if __GLASGOW_HASKELL__ >= 703
    RtsFlags.GcFlags.idleGCDelayTime = SecondsToTime(5);
#else
    RtsFlags.GcFlags.idleGCDelayTime = 5*1000;
#endif
}
예제 #9
0
//--------------------------------------------------------------------------
bool GetStatistics(const bool verbose, UINT32 snapLen)
{
	bool        rc = false;
	DWORD       bytesReturned;
	HANDLE      driver;
	STATISTICS  statistics;
	TIME        loadedTime;
	TIME        loggingTime;

	driver = OpenDriver(verbose);
	if (driver == INVALID_HANDLE_VALUE) {
		goto Cleanup;
	}

	if (snapLen) {
		if (!DeviceIoControl(driver, IOCTL_HONE_SET_SNAP_LENGTH, &snapLen,
				sizeof(UINT32), NULL, 0, &bytesReturned, NULL)) {
			LogError("Cannot send IOCTL to set snap length");
			goto Cleanup;
		}
	}

	if (!DeviceIoControl(driver, IOCTL_HONE_GET_STATISTICS, NULL, 0,
			&statistics, sizeof(statistics), &bytesReturned, NULL)) {
		LogError("Cannot send IOCTL to get snap length", stdout);
		goto Cleanup;
	}

	SecondsToTime(statistics.LoadedTime,  loadedTime);
	SecondsToTime(statistics.LoggingTime, loggingTime);

	printf(
		"Driver version . . . . . . . . . . . . . . . . . . %u.%u.%u\n"
		"Time elapsed since driver was loaded . . . . . . . %u days %u hours %u minutes %u seconds\n"
		"Time driver has had readers attached . . . . . . . %u days %u hours %u minutes %u seconds\n"
		"Total number of readers since driver was loaded  . %u\n"
		"Number of readers  . . . . . . . . . . . . . . . . %u\n"
		"Number of processes tracked by the driver  . . . . %u\n"
		"Number of connections tracked by the driver  . . . %u\n"
		"Ring buffer size . . . . . . . . . . . . . . . . . %u\n"
		"Maximum snap length  . . . . . . . . . . . . . . . %u\n"
		"This reader's ID . . . . . . . . . . . . . . . . . %u\n"
		"This reader's ring buffer size . . . . . . . . . . %u\n"
		"This reader's snap length  . . . . . . . . . . . . %u\n"
		"Total number of packets captured . . . . . . . . . %I64u\n"
		"Total number of packet bytes captured  . . . . . . %I64u\n"
		"Total number of process start events . . . . . . . %u\n"
		"Total number of process end events . . . . . . . . %u\n"
		"Total number of connection open events . . . . . . %u\n"
		"Total number of connection close events  . . . . . %u\n",
		statistics.VersionMajor, statistics.VersionMinor, statistics.VersionMicro,
		loadedTime.Days,  loadedTime.Hours,  loadedTime.Minutes,  loadedTime.Seconds,
		loggingTime.Days, loggingTime.Hours, loggingTime.Minutes, loggingTime.Seconds,
		statistics.TotalReaders,
		statistics.NumReaders,
		statistics.NumProcesses,
		statistics.NumConnections,
		statistics.RingBufferSize,
		statistics.MaxSnapLength,
		statistics.ReaderId,
		statistics.ReaderBufferSize,
		statistics.ReaderSnapLength,
		statistics.CapturedPackets,
		statistics.CapturedPacketBytes,
		statistics.ProcessStartEvents,
		statistics.ProcessEndEvents,
		statistics.ConnectionOpenEvents,
		statistics.ConnectionCloseEvents);
	rc = true;

Cleanup:
	if (driver != INVALID_HANDLE_VALUE) {
		CloseHandle(driver);
	}
	return rc;
}
예제 #10
0
파일: GetTime.c 프로젝트: NathanHowell/ghc
Time getProcessElapsedTime(void)
{
    struct timeval tv;
    gettimeofday(&tv, (struct timezone *) NULL);
    return SecondsToTime(tv.tv_sec) + USToTime(tv.tv_usec);
}
예제 #11
0
파일: car.cpp 프로젝트: Milun/Swag-Cars
void Car::Draw()
{
	Update();

	if (yDraw < (float)(y - 1) || yDraw >(float)(y + 1))
	{
		yDraw += ((float)y - yDraw) / 10.0f;
	}

	int yInt = (int)yDraw;

	if (mode == 'n' && y <= -200)
	{
		DrawRect(x, y, 122, 135, color.r, color.g, color.b);

		if (btnBubble->ClickedOnThisFrame() && gPause)
		{
			mode = 'w';
			chargeCurrent = 0.0;
			timeDue = gTime + addTime;
			active = false;
		}

		btnBubble->Draw();
	}
	else
	{
		active = true;

		//sprite->Draw(x, yInt);
		DrawRect(x, yInt, 122, 192, color.r, color.g, color.b);


		text->Draw(x + 5, yInt + 10, "Chrg:     " + std::to_string(((int)chargeCurrent)) + "%");
		text->Draw(x + 5, yInt + 25, "ChrgRate: " + std::to_string((int)(chargeRate*gFramesToSeconds)) + "ps");

		text->Draw(x + 5, yInt + 50, "TimeWait: " + SecondsToTime(waitTime));

		if (timeDue + GetChargeTime() >= gTime) text->Draw(x + 5, yInt + 80, "TimeToCh: " + ToTime(GetChargeTime()), 0, 150, 0);
		else									text->Draw(x + 5, yInt + 80, "TimeToCh: " + ToTime(GetChargeTime()), 150, 0, 0);

		if (timeDue >= gTime)	text->Draw(x + 5, yInt + 95, "TimeDue:  " + SecondsToTime(timeDue), 0, 225, 0);
		else					text->Draw(x + 5, yInt + 95, "TimeDue:  " + SecondsToTime(timeDue), 225, 0, 0);


		//text->Draw(x + 20, yInt + 30, "Max: " + std::to_string((int)(chargeMax)) + "kWh");
		//text->Draw(x + 20, yInt + 110, "Use: " + std::to_string((int)(chargeUse*100.0f)) + "pf");

		std::string bar = "";
		for (unsigned i = 0; i < (int)chargeCurrent; i += 10)
		{
			bar += "|";
		}

		text->Draw(x + 24, yInt + 140, bar, 0, 200, 0);

		if (gPause)
		{
			btnReturn->y = yInt + 160;
			btnReturn->Draw();
		}

		if (btnReturn->ClickedOnThisFrame() && gPause)
		{
			Reset();
		}

		if (gPause)
		{
			btnL1->y = yInt + 75;
			btnR1->y = yInt + 75;
			btnL2->y = yInt + 92;
			btnR2->y = yInt + 92;

			if (btnL1->Clicked())
			{
				if (GetChargeTime() > 0.01)
				{
					chargeRate += 0.0005;
				}
			}
			if (btnR1->Clicked())
			{
				if (chargeRate > 0.005)
				{
					chargeRate -= 0.0005;

					if (timeDue < gTime + GetMaxChargeTime() + 1)
					{
						addTime = GetMaxChargeTime() + 1;
						timeDue = gTime + addTime;
					}
				}
			}

			if (btnR2->Clicked())
			{
				addTime += 0.1;
				timeDue = gTime + addTime;
			}
			if (btnL2->Clicked())
			{
				if (timeDue > gTime + GetMaxChargeTime() + 1)
				{
					addTime -= 0.1;
					timeDue = gTime + addTime;
				}
			}

			btnL1->Draw();
			btnR1->Draw();
			btnL2->Draw();
			btnR2->Draw();
		}
	}
}
예제 #12
0
PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
	Measure* measure = (Measure*)data;
	ParentMeasure* parent = measure->parent;
	if (!parent) return nullptr;

	const Player* player = parent->player;
	static WCHAR buffer[32];

	switch (measure->type)
	{
	case MEASURE_ARTIST:
		return player->GetArtist();

	case MEASURE_TITLE:
		return player->GetTitle();

	case MEASURE_ALBUM:
		return player->GetAlbum();

	case MEASURE_LYRICS:
		return player->GetLyrics();

	case MEASURE_COVER:
		return player->GetCoverPath();

	case MEASURE_FILE:
		return player->GetFilePath();

	case MEASURE_DURATION:
		SecondsToTime(player->GetDuration(), parent->disableLeadingZero, buffer);
		return buffer;

	case MEASURE_POSITION:
		SecondsToTime(player->GetPosition(), parent->disableLeadingZero, buffer);
		return buffer;

	case MEASURE_PROGRESS:
		_itow_s(player->GetDuration() ? ((player->GetPosition() * 100) / player->GetDuration()) : 0, buffer, 10);
		return buffer;

	case MEASURE_RATING:
		_itow_s(player->GetRating(), buffer, 10);
		return buffer;

	case MEASURE_VOLUME:
		_itow_s(player->GetVolume(), buffer, 10);
		return buffer;

	case MEASURE_STATE:
		_itow_s(player->GetState(), buffer, 10);
		return buffer;

	case MEASURE_STATUS:
		_itow_s((int)player->IsInitialized(), buffer, 10);
		return buffer;

	case MEASURE_SHUFFLE:
		_itow_s((int)player->GetShuffle(), buffer, 10);
		return buffer;

	case MEASURE_REPEAT:
		_itow_s((int)player->GetRepeat(), buffer, 10);
		return buffer;

	case MEASURE_NUMBER:
		_itow_s(player->GetNumber(), buffer, 10);
		return buffer;

	case MEASURE_YEAR:
		_itow_s(player->GetYear(), buffer, 10);
		return buffer;
	}

	return nullptr;
}
예제 #13
0
void CCopyMapUISurvive::ScheduleSurviveSeconds(float dt)
{
	//激活前倒计时,激活后战斗统计时间
	m_nSurviveSeconds++;
	m_pSurviveSeconds->setText(SecondsToTime(m_nSurviveSeconds,1));
}