本文整理汇总了C++中Microseconds函数的典型用法代码示例。如果您正苦于以下问题:C++ Microseconds函数的具体用法?C++ Microseconds怎么用?C++ Microseconds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Microseconds函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: display_update
/* If this function is NULL, polling is not needed */
static int display_update(void *handle, void *device,
int x, int y, int w, int h)
{
UInt64 t1;
UInt64 t2;
int delta;
IMAGE *img = image_find(handle, device);
if (img == NULL)
return -1;
Microseconds((UnsignedWide*)&t1);
delta = (t1 - img->update_time) / 1000000L;
if (img->update_interval < 1)
img->update_interval = 1; /* seconds */
if (delta < 0)
img->update_time = t1;
else if (delta > img->update_interval)
{
/* redraw window */
window_invalidate(img->windowRef);
/* Make sure the update interval is at least 10 times
* what it takes to paint the window
*/
Microseconds((UnsignedWide*)&t2);
delta = (t2 - t1) / 1000;
if (delta < 0)
delta += 60000; /* delta = time to redraw */
if (delta > img->update_interval * 100)
img->update_interval = delta/100;
img->update_time = t2;
}
return gsdll_poll(handle);
}
开发者ID:hackqiang,项目名称:gs,代码行数:36,代码来源:dmmain.c
示例2: _GSocket_Output_Timeout
/* _GSocket_Output_Timeout:
* For blocking sockets, wait until data can be sent without
* blocking or until timeout ellapses.
*/
GSocketError _GSocket_Output_Timeout(GSocket *socket)
{
if ( !socket->m_non_blocking )
{
UnsignedWide now , start ;
short formerTakesEvents = socket->m_takesEvents ;
Microseconds(&start);
now = start ;
socket->m_takesEvents = FALSE ;
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{
OTResult state ;
state = OTGetEndpointState(socket->m_endpoint);
if ( state == T_DATAXFER || state == T_INREL )
{
socket->m_takesEvents = formerTakesEvents ;
return GSOCK_NOERROR;
}
Microseconds(&now);
}
socket->m_takesEvents = formerTakesEvents ;
socket->m_error = GSOCK_TIMEDOUT;
return GSOCK_TIMEDOUT;
}
return GSOCK_NOERROR;
}
开发者ID:EdgarTx,项目名称:wx,代码行数:32,代码来源:gsocket.c
示例3: TEST
TEST(DurationTest, Timeval)
{
EXPECT_EQ(Duration(timeval{10, 0}), Seconds(10));
EXPECT_EQ(Duration(timeval{0, 7}), Microseconds(7));
EXPECT_EQ(Duration(timeval{2, 123}), Seconds(2) + Microseconds(123));
timeval t{2, 123};
Duration d(t);
EXPECT_EQ(d.timeval().tv_sec, t.tv_sec);
EXPECT_EQ(d.timeval().tv_usec, t.tv_usec);
t.tv_usec = 0;
d = Duration(t);
EXPECT_EQ(d.timeval().tv_sec, t.tv_sec);
EXPECT_EQ(d.timeval().tv_usec, t.tv_usec);
// Negative times.
t.tv_sec = 0;
t.tv_usec = -1;
d = Duration(t);
EXPECT_EQ(d.timeval().tv_sec, t.tv_sec);
EXPECT_EQ(d.timeval().tv_usec, t.tv_usec);
d = Microseconds(-1);
EXPECT_EQ(d.timeval().tv_sec, t.tv_sec);
EXPECT_EQ(d.timeval().tv_usec, t.tv_usec);
t.tv_sec = -1;
t.tv_usec = -30;
d = Duration(t);
EXPECT_EQ(d.timeval().tv_sec, t.tv_sec);
EXPECT_EQ(d.timeval().tv_usec, t.tv_usec);
}
开发者ID:CodeTickler,项目名称:mesos,代码行数:33,代码来源:duration_tests.cpp
示例4: SoundTask
static void * SoundTask(void *)
{
long long curt;
static long long last;
Microseconds((UnsignedWide *) &last);
while (!stopNow)
{
if (!mboxPause)
{
if (musicboxmode == kMBXSoundEmulation)
SPCPlayExec();
else
S9xMainLoop();
}
last += (1000000 / Memory.ROMFramesPerSecond);
Microseconds((UnsignedWide *) &curt);
if (last > curt)
usleep(last - curt);
}
return nil;
}
开发者ID:BruceJawn,项目名称:flashsnes,代码行数:26,代码来源:mac-musicbox.cpp
示例5: main
int main(int argc, char *argv[]) {
int i, j, k, ret, loops, freq, log2_N, jobs, N, mb = mbox_open();
unsigned t[2];
double tsq[2];
GPU_FFT_COMPLEX *base;
struct GPU_FFT *fft;
log2_N = argc>1? atoi(argv[1]) : 12; // 8 <= log2_N <= 21
jobs = argc>2? atoi(argv[2]) : 1; // transforms per batch
loops = argc>3? atoi(argv[3]) : 1; // test repetitions
if (argc<2 || jobs<1 || loops<1) {
printf(Usage);
return -1;
}
N = 1<<log2_N; // FFT length
ret = gpu_fft_prepare(mb, log2_N, GPU_FFT_REV, jobs, &fft); // call once
switch(ret) {
case -1: printf("Unable to enable V3D. Please check your firmware is up to date.\n"); return -1;
case -2: printf("log2_N=%d not supported. Try between 8 and 21.\n", log2_N); return -1;
case -3: printf("Out of memory. Try a smaller batch or increase GPU memory.\n"); return -1;
case -4: printf("Unable to map Videocore peripherals into ARM memory space.\n"); return -1;
}
for (k=0; k<loops; k++) {
for (j=0; j<jobs; j++) {
base = fft->in + j*fft->step; // input buffer
for (i=0; i<N; i++) base[i][0] = base[i][1] = 0;
freq = j+1;
base[freq][0] = base[N-freq][0] = 0.5;
}
usleep(1); // Yield to OS
t[0] = Microseconds();
gpu_fft_execute(fft); // call one or many times
t[1] = Microseconds();
tsq[0]=tsq[1]=0;
for (j=0; j<jobs; j++) {
base = fft->out + j*fft->step; // output buffer
freq = j+1;
for (i=0; i<N; i++) {
double re = cos(2*GPU_FFT_PI*freq*i/N);
tsq[0] += pow(re, 2);
tsq[1] += pow(re - base[i][0], 2) + pow(base[i][1], 2);
}
}
printf("rel_rms_err = %0.2g, usecs = %d, k = %d\n",
sqrt(tsq[1]/tsq[0]), (t[1]-t[0])/jobs, k);
}
gpu_fft_release(fft); // Videocore memory lost if not freed !
return 0;
}
开发者ID:EQ4,项目名称:gpu_fftw,代码行数:59,代码来源:hello_fft.c
示例6: TclpGetTime
void
TclpGetTime(
Tcl_Time *timePtr) /* Location to store time information. */
{
UnsignedWide micro;
#ifndef NO_LONG_LONG
long long *microPtr;
#endif
if (initalized == false) {
MachineLocation loc;
long int offset;
ReadLocation(&loc);
offset = loc.u.gmtDelta & 0x00ffffff;
if (offset & 0x00800000) {
offset = offset | 0xff000000;
}
if (ReadDateTime(&baseSeconds) != noErr) {
/*
* This should never happen!
*/
return;
}
/*
* Remove the local offset that ReadDateTime() adds.
*/
baseSeconds -= offset;
Microseconds(µOffset);
initalized = true;
}
Microseconds(µ);
#ifndef NO_LONG_LONG
microPtr = (long long *) µ
*microPtr -= *((long long *) µOffset);
timePtr->sec = baseSeconds + (*microPtr / 1000000);
timePtr->usec = *microPtr % 1000000;
#else
SubtractUnsignedWide(µ, µOffset, µ);
/*
* This lovely computation is equal to: base + (micro / 1000000)
* For the .hi part the ratio of 0x100000000 / 1000000 has been
* reduced to avoid overflow. This computation certainly has
* problems as the .hi part gets large. However, your application
* would have to run for a long time to make that happen.
*/
timePtr->sec = baseSeconds + (micro.lo / 1000000) +
(long) (micro.hi * ((double) 33554432.0 / 15625.0));
timePtr->usec = micro.lo % 1000000;
#endif
}
开发者ID:AndresGG,项目名称:sn-8.4,代码行数:55,代码来源:tclMacTime.c
示例7: Sys_Timer
float Sys_Timer(void) {
static UInt64 start = 0;
UInt64 counter = 0;
if (start == 0) {
Microseconds((UnsignedWide *)&start);
return 0.0f;
}
Microseconds((UnsignedWide *)&counter);
return (counter - start) / 1000000.0f;
}
开发者ID:davidreynolds,项目名称:Atlas2D,代码行数:12,代码来源:apple.c
示例8: glBindTexture
void GLtexture::copyFramebuffer(const Rect& r)
{
glBindTexture(GL_TEXTURE_2D, getObject());
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r.x, r.y, r.width, r.height);
#if 0
ulonglong_t start = Microseconds();
ulonglong_t end = Microseconds();
Printf("GLtexture::copyFramebuffer: %d microseconds\n", end - start);
GLrender::checkErrors();
#endif
}
开发者ID:CharlieCraft,项目名称:axonengine,代码行数:13,代码来源:gltexture.cpp
示例9: defined
void flext::Sleep(double s)
{
if(s <= 0) return;
#if FLEXT_OS == FLEXT_OS_WIN
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x400
#if 0
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = (LONGLONG)(-1.e7*s);
// Create a waitable timer.
HANDLE hTimer = CreateWaitableTimer(NULL,TRUE,NULL);
if(hTimer) {
if(SetWaitableTimer(hTimer,&liDueTime,0,NULL,NULL,0))
// Wait for the timer.
WaitForSingleObject(hTimer,INFINITE); // != WAIT_OBJECT_0)
else
::Sleep((long)(s*1000.));
CloseHandle(hTimer);
}
else
#else
LARGE_INTEGER cnt;
if(perffrq && QueryPerformanceCounter(&cnt)) {
LONGLONG dst = (LONGLONG)(cnt.QuadPart+perffrq*s);
for(;;) {
SwitchToThread(); // while waiting switch to another thread
QueryPerformanceCounter(&cnt);
if(cnt.QuadPart > dst) break;
}
}
else
#endif
#endif
// last resort....
::Sleep((long)(s*1000.));
#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH // POSIX
usleep((long)(s*1000000.));
#elif FLEXT_OS == FLEXT_OS_MAC // that's just for OS9 & Carbon!
UnsignedWide tick;
Microseconds(&tick);
double target = tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo+s*1.e6;
for(;;) {
// this is just a loop running until the time has passed - stone age (but we yield at least)
Microseconds(&tick);
if(target <= tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo) break;
YieldToAnyThread(); // yielding surely reduces the timing precision (but we're civilized)
}
#else
#error Not implemented
#endif
}
开发者ID:alikthename,项目名称:Satellite-CCRMA-Userland-Scripts-And-Examples-Ubuntu,代码行数:51,代码来源:fltimer.cpp
示例10: ProfileOperaPop
void ProfileOperaPop() // PROFILE_OPERA_POP(x)
{
if (s_profile_opera_file && s_profile_opera_data.GetCount())
{
unsigned long long current_time;
Microseconds((UnsignedWide*) ¤t_time);
ProfileOperaData* data = s_profile_opera_data.Remove(s_profile_opera_data.GetCount()-1);
unsigned long long long_delta = current_time - data->m_start_time;
unsigned int delta = (unsigned long)((long_delta+500)/1000);
if (delta >= 10)
{
for (UINT32 i = 0; i < s_profile_opera_data.GetCount(); i++)
{
fprintf(s_profile_opera_file, " ");
}
fprintf(s_profile_opera_file,"%08llu: %4u\n", data->m_unique_id, delta);
fflush(s_profile_opera_file);
}
delete data;
}
}
开发者ID:prestocore,项目名称:browser,代码行数:25,代码来源:mac_profile.cpp
示例11: noise_get_light
/*
* This function is called every time the random pool needs
* stirring, and will acquire the system time.
*/
void noise_get_light(void (*func) (void *, int))
{
UnsignedWide utc;
Microseconds(&utc);
func(&utc, sizeof(utc));
}
开发者ID:svn2github,项目名称:kitty,代码行数:11,代码来源:macnoise.c
示例12: GetTimestampMilliseconds
NMUInt32 GetTimestampMilliseconds()
{
NMUInt32 timestamp = 0;
NMUInt32 clocksPerSec;
#ifdef OP_PLATFORM_MAC_CFM
double clocks;
#else
clock_t clocks;
#endif
#ifdef OP_PLATFORM_MAC_CFM
UnsignedWide mSeconds;
clocksPerSec = 1000000; // Magic Number = Microseconds
Microseconds( &mSeconds );
// Convert to appropriate type in the floating point domain
clocks = ( mSeconds.hi * 4294967296.0 + mSeconds.lo );
#else
clocksPerSec = MACHINE_TICKS_PER_SECOND;
clocks = machine_tick_count();
#endif
timestamp = (NMUInt32)((clocks / (double)clocksPerSec) * (double)MILLISECS_PER_SEC);
return timestamp;
}
开发者ID:MaddTheSane,项目名称:tntbasic,代码行数:30,代码来源:OPUtils.cpp
示例13: gentime
globle double gentime()
{
#if MAC
UnsignedWide result;
Microseconds(&result);
return(((((double) result.hi) * kTwoPower32) + result.lo) / 1000000.0);
#endif
#if IBM_MCW
unsigned long int result;
result = GetTickCount();
return((double) result / 1000.0);
#endif
#if IBM_TBC && (! WINDOW_INTERFACE)
unsigned long int result;
result = biostime(0,(long int) 0);
return((double) result / 18.2);
#endif
#if GENERIC || (! MAC)
return((double) clock() / (double) CLOCKS_PER_SEC);
#endif
}
开发者ID:pandaxcl,项目名称:CLIPS-unicode,代码行数:30,代码来源:sysdep.c
示例14: GetSystemTime
double flext::GetOSTime()
{
double tm;
#if FLEXT_OS == FLEXT_OS_WIN
LARGE_INTEGER cnt;
if(perffrq && QueryPerformanceCounter(&cnt))
tm = cnt.QuadPart/perffrq;
else {
SYSTEMTIME systm;
FILETIME fltm;
GetSystemTime(&systm);
SystemTimeToFileTime(&systm,&fltm);
tm = ((LARGE_INTEGER *)&fltm)->QuadPart*1.e-7;
}
#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH // POSIX
timeval tmv;
gettimeofday(&tmv,NULL);
tm = tmv.tv_sec+tmv.tv_usec*1.e-6;
#elif FLEXT_OS == FLEXT_OS_MAC // that's just for OS9 & Carbon!
UnsignedWide tick;
Microseconds(&tick);
tm = (tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo)*1.e-6;
#else
#error Not implemented
#endif
return tm-starttime;
}
开发者ID:alikthename,项目名称:Satellite-CCRMA-Userland-Scripts-And-Examples-Ubuntu,代码行数:28,代码来源:fltimer.cpp
示例15: macos_gettick
UINT32 macos_gettick(void) {
UnsignedWide current;
Microseconds(¤t);
return((UINT32)((current.hi * 4294967) + (current.lo / 1000)));
}
开发者ID:FREEWING-JP,项目名称:np2pi,代码行数:7,代码来源:macossub.cpp
示例16: Microseconds
void MacOpTimer::Start(UINT32 ms)
{
UnsignedWide ticks;
Microseconds(&ticks);
long long msecs = ticks.hi;
msecs <<= 32;
msecs |= ticks.lo;
m_startTime = msecs / 1000;
m_interval = ms;
EventTimerInterval fireDelay = ms * kEventDurationMillisecond;
if (m_timerRef)
{
SetEventLoopTimerNextFireTime(m_timerRef,fireDelay);
}
else
{
InstallEventLoopTimer(gMainEventLoop,//GetMainEventLoop(),
fireDelay,
kEventDurationNoWait,
timerUPP,
this,
&m_timerRef);
}
}
开发者ID:prestocore,项目名称:browser,代码行数:26,代码来源:MacOpTimer.cpp
示例17: EdenTimeInSeconds
//
// Get time in fractional seconds.
// Supported via system calls on Unix, WIN32, and MacOS.
// Other systems which support GLUT are also supported (with lesser accuracy.)
//
double EdenTimeInSeconds(void)
{
#if defined(EDEN_UNIX)
struct timeval tv; // Seconds and microseconds since Jan 1, 1970.
#elif defined(_WIN32)
FILETIME ft; // Hundreds of nanoseconds since Jan 1, 1601.
#elif defined(EDEN_MACOS)
UnsignedWide _time;
#else
int ms;
#endif
#if defined(EDEN_UNIX)
gettimeofday(&tv, NULL);
return ((double)tv.tv_sec + (double)tv.tv_usec * 0.000001);
#elif defined(_WIN32)
GetSystemTimeAsFileTime(&ft);
return ((double)(*((LONGLONG *)&ft) - FILETIME_TO_EPOCH_OFFSET) * 0.0000001);
#elif defined(EDEN_MACOS)
Microseconds(&_time);
return (4294.967296 * (double)_time.hi + 0.000001 * (double)_time.lo); // 2^32 = 4294967296.
#else
ms = glutGet(GLUT_ELAPSED_TIME);
return ((double)ms / 1000.0);
#endif
}
开发者ID:AadityaDev,项目名称:artoolkit5,代码行数:32,代码来源:EdenTime.c
示例18: consumeFrequency
static bool consumeFrequency(const char* input, int* index, Microseconds* result) {
const char* expectedToken;
double val;
if (!consumeDouble(input, index, &val)) {
return false;
}
consumeWhitespace(input, index);
switch (input[*index]) {
case 'H':
expectedToken = "Hz";
break;
case 'k':
expectedToken = "kHz";
val *= 1000;
break;
default:
return false;
}
*result = Microseconds(1000000/val);
return consumeToken(expectedToken, input, index);
}
开发者ID:CWRUChielLab,项目名称:ArduinoPulseGenerator,代码行数:27,代码来源:pulseStateMachine.cpp
示例19: TEST_F
TEST_F(KeysManagerShardedTest, GetKeyForValidationTimesOutIfRefresherIsNotRunning) {
operationContext()->setDeadlineAfterNowBy(Microseconds(250 * 1000));
ASSERT_THROWS(keyManager()
->getKeyForValidation(operationContext(), 1, LogicalTime(Timestamp(100, 0)))
.status_with_transitional_ignore(),
DBException);
}
开发者ID:DINKIN,项目名称:mongo,代码行数:8,代码来源:keys_collection_manager_sharding_test.cpp
示例20: cputime
int
cputime ()
{
UnsignedWide msecs;
Microseconds (&msecs);
return(int)(*(long long *)&msecs / 1000);
}
开发者ID:macssh,项目名称:macssh,代码行数:8,代码来源:divrem.c
注:本文中的Microseconds函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论