mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
gethitickms(): replace division by multiplication.
git-svn-id: https://svn.eduke32.com/eduke32@2856 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
69365f2a0b
commit
e7d3dcba78
3 changed files with 10 additions and 10 deletions
|
@ -778,7 +778,7 @@ void releaseallbuttons(void)
|
||||||
static Uint32 timerfreq=0;
|
static Uint32 timerfreq=0;
|
||||||
static Uint32 timerlastsample=0;
|
static Uint32 timerlastsample=0;
|
||||||
int32_t timerticspersec=0;
|
int32_t timerticspersec=0;
|
||||||
static double hiticksperms = 1e308;
|
static double msperhitick = 0;
|
||||||
static void(*usertimercallback)(void) = NULL;
|
static void(*usertimercallback)(void) = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,7 +797,7 @@ int32_t inittimer(int32_t tickspersecond)
|
||||||
|
|
||||||
usertimercallback = NULL;
|
usertimercallback = NULL;
|
||||||
|
|
||||||
hiticksperms = (double)gethitickspersec() / 1000;
|
msperhitick = 1000.0 / (double)gethitickspersec();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ void uninittimer(void)
|
||||||
|
|
||||||
timerfreq=0;
|
timerfreq=0;
|
||||||
|
|
||||||
hiticksperms = 1e308;
|
msperhitick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -883,7 +883,7 @@ uint64_t gethitickspersec(void)
|
||||||
ATTRIBUTE((flatten))
|
ATTRIBUTE((flatten))
|
||||||
double gethitickms(void)
|
double gethitickms(void)
|
||||||
{
|
{
|
||||||
return (double)gethiticks() / hiticksperms;
|
return (double)gethiticks() * msperhitick;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ static const char *GetDInputError(HRESULT code)
|
||||||
static int64_t timerfreq=0;
|
static int64_t timerfreq=0;
|
||||||
static int32_t timerlastsample=0;
|
static int32_t timerlastsample=0;
|
||||||
int32_t timerticspersec=0;
|
int32_t timerticspersec=0;
|
||||||
static double hiticksperms = 1e308;
|
static double msperhitick = 0;
|
||||||
static void (*usertimercallback)(void) = NULL;
|
static void (*usertimercallback)(void) = NULL;
|
||||||
|
|
||||||
// This timer stuff is all Ken's idea.
|
// This timer stuff is all Ken's idea.
|
||||||
|
@ -1603,7 +1603,7 @@ int32_t inittimer(int32_t tickspersecond)
|
||||||
|
|
||||||
usertimercallback = NULL;
|
usertimercallback = NULL;
|
||||||
|
|
||||||
hiticksperms = (double)gethitickspersec() / 1000;
|
msperhitick = 1000.0 / (double)gethitickspersec();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1618,7 +1618,7 @@ void uninittimer(void)
|
||||||
timerfreq=0;
|
timerfreq=0;
|
||||||
timerticspersec = 0;
|
timerticspersec = 0;
|
||||||
|
|
||||||
hiticksperms = 1e308;
|
msperhitick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1672,7 +1672,7 @@ uint64_t gethitickspersec(void)
|
||||||
ATTRIBUTE((flatten))
|
ATTRIBUTE((flatten))
|
||||||
double gethitickms(void)
|
double gethitickms(void)
|
||||||
{
|
{
|
||||||
return (double)gethiticks() / hiticksperms;
|
return (double)gethiticks() * msperhitick;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -203,8 +203,8 @@ gameevent(gv.EVENT_ENTERLEVEL,
|
||||||
|
|
||||||
t = gv.gethitickms()-t
|
t = gv.gethitickms()-t
|
||||||
|
|
||||||
-- x86_64: 40ns/call, x86: 290 ns/call
|
-- x86_64: 35ns/call, x86: 290 ns/call?
|
||||||
-- Windows 32-bit: about 1 us/call
|
-- Windows 32-bit: about 1 us/call?
|
||||||
printf("%d gethitickms() calls took %.03f ms (%.03f us/call)",
|
printf("%d gethitickms() calls took %.03f ms (%.03f us/call)",
|
||||||
N, t, (t*1000)/N)
|
N, t, (t*1000)/N)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue