SyntaxBomb - Indie Coders
Languages & Coding => BlitzMax / BlitzMax NG => Topic started by: Scaremonger on November 09, 2020, 17:10:22
Hi,
Is the data type "long long" equivalent to BlitzMaxNG Int128 datatype or is it a ULong?
I have finally got around to updating Fungicide after it stuttered it's way into fourth place in the Nov-Jan 2018 "Retro" game competition. I already know that the main issue is with my game loop, but I have been digging around for other issues too. One of the first things I looked at was timing. I had chosen to use a modified form of ImaginaryHumans MilliSecsLong() function and I've found it is very slow compared to the standard MilliSecs() function. A million iterations gave me:
MilliSecs(): 89ms
MilliSecsLong(): 226ms
The reason I went for the MilliSecsLong() function was because of Integer rollover, so it got me looking at the MinGW C Library and I threw together this function:
milli.c
#include "time.h"
#include <sys/time.h>
long long Milli(void) {
struct timeval tv;
gettimeofday( &tv, NULL );
return (( (long long)tv.tv_sec )*1000 )+( tv.tv_usec/1000 );
}
Blitzmax:
Import "milli.c"
Extern
Function Milli:Int128()
End Extern
local time:int128 = Milli()
A million iterations now gave me:
MilliSecs(): 92ms
MilliSecsLong(): 236ms
Milli(): 89ms
So back to my initial question... Is int128 the correct datatype?
Fungicide: https://www.syntaxbomb.com/index.php/topic,3984.0.html (https://www.syntaxbomb.com/index.php/topic,3984.0.html)
Competition: https://www.syntaxbomb.com/index.php/topic,3997.0.html (https://www.syntaxbomb.com/index.php/topic,3997.0.html)
MilliSecsLong(): https://www.syntaxbomb.com/index.php?topic=2349.0 (https://www.syntaxbomb.com/index.php?topic=2349.0)
Regards,
Si...
Hi,
nope. Bmax Ng equivalent of a C long long (64 bit signed integer) is just plain long :-) Int128 is a special SIMD datatype which I'm not that familiar with.
See here https://blitzmax.org/docs/en/language/data_types/ (https://blitzmax.org/docs/en/language/data_types/)
-Henri
Thanks @Henri
So the blitzmax part of the code should be:
Import "milli.c"
Extern
Function Milli:Long()
End Extern
local time:Long = Milli()
print time
While this is a good "speedup" ... how often are you calling Millisecs() a second? :D
Bye
Ron aka "A MillisecsLong() user"
Hardly the point of slowdown in any game - a call to a system timer.