mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 01:55:19 -04:00
avoid 64 bit integer division in Stopwatch_ElapsedMilliseconds, ~200 lines less in webclient
This commit is contained in:
parent
10c958eed9
commit
f8e1df2e21
@ -1005,7 +1005,7 @@ static void WorkerLoop(void) {
|
|||||||
request.result = Http_BackendDo(&request, &url);
|
request.result = Http_BackendDo(&request, &url);
|
||||||
end = Stopwatch_Measure();
|
end = Stopwatch_Measure();
|
||||||
|
|
||||||
elapsed = (int)Stopwatch_ElapsedMilliseconds(beg, end);
|
elapsed = Stopwatch_ElapsedMilliseconds(beg, end);
|
||||||
Platform_Log4("HTTP: result %i (http %i) in %i ms (%i bytes)",
|
Platform_Log4("HTTP: result %i (http %i) in %i ms (%i bytes)",
|
||||||
&request.result, &request.statusCode, &elapsed, &request.size);
|
&request.result, &request.statusCode, &elapsed, &request.size);
|
||||||
Http_FinishRequest(&request);
|
Http_FinishRequest(&request);
|
||||||
|
@ -191,8 +191,10 @@ cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
|||||||
return ((end - beg) * sw_freqMul) / sw_freqDiv;
|
return ((end - beg) * sw_freqMul) / sw_freqDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_uint64 Stopwatch_ElapsedMilliseconds(cc_uint64 beg, cc_uint64 end) {
|
int Stopwatch_ElapsedMilliseconds(cc_uint64 beg, cc_uint64 end) {
|
||||||
return Stopwatch_ElapsedMicroseconds(beg, end) / 1000;
|
cc_uint64 raw = Stopwatch_ElapsedMicroseconds(beg, end);
|
||||||
|
if (raw > Int32_MaxValue) return Int32_MaxValue / 1000;
|
||||||
|
return (int)raw / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined CC_BUILD_WIN
|
#if defined CC_BUILD_WIN
|
||||||
|
@ -141,7 +141,7 @@ CC_API cc_uint64 Stopwatch_Measure(void);
|
|||||||
/* Returns total elapsed microseconds between two stopwatch measurements. */
|
/* Returns total elapsed microseconds between two stopwatch measurements. */
|
||||||
CC_API cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end);
|
CC_API cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end);
|
||||||
/* Returns total elapsed milliseconds between two stopwatch measurements. */
|
/* Returns total elapsed milliseconds between two stopwatch measurements. */
|
||||||
CC_API cc_uint64 Stopwatch_ElapsedMilliseconds(cc_uint64 beg, cc_uint64 end);
|
CC_API int Stopwatch_ElapsedMilliseconds(cc_uint64 beg, cc_uint64 end);
|
||||||
|
|
||||||
/* Returns non-zero if the given directory exists. */
|
/* Returns non-zero if the given directory exists. */
|
||||||
CC_API int Directory_Exists(const cc_string* path);
|
CC_API int Directory_Exists(const cc_string* path);
|
||||||
|
@ -534,7 +534,7 @@ static void Classic_LevelFinalise(cc_uint8* data) {
|
|||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
end = Stopwatch_Measure();
|
end = Stopwatch_Measure();
|
||||||
delta = (int)Stopwatch_ElapsedMilliseconds(map_receiveBeg, end);
|
delta = Stopwatch_ElapsedMilliseconds(map_receiveBeg, end);
|
||||||
Platform_Log1("map loading took: %i", &delta);
|
Platform_Log1("map loading took: %i", &delta);
|
||||||
map_begunLoading = false;
|
map_begunLoading = false;
|
||||||
WoM_CheckSendWomID();
|
WoM_CheckSendWomID();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user