tickcount returns in 10th's of the second in linux
#1

After having some headache with race times in linux, I realised that tickcount did not return in milliseconds.
Here's a comparison between tickcount
and GetTickCount

This only happen in linux.

Код:
[21:33:59] GetTickCount - 60928
[21:33:59] tickcount - 1120
[21:33:59] GetTickCount - 61131
[21:33:59] tickcount - 1120
[21:33:59] GetTickCount - 61334
[21:33:59] tickcount - 1120
[21:33:59] GetTickCount - 61538
[21:33:59] tickcount - 1120
[21:34:00] GetTickCount - 61742
[21:34:00] tickcount - 1130
[21:34:00] GetTickCount - 61946
[21:34:00] tickcount - 1130
[21:34:00] GetTickCount - 62149
[21:34:00] tickcount - 1130
[21:34:00] GetTickCount - 62352
[21:34:00] tickcount - 1130
[21:34:00] GetTickCount - 62556
[21:34:00] tickcount - 1130
[21:34:01] GetTickCount - 62760
[21:34:01] tickcount - 1140
[21:34:01] GetTickCount - 62964
[21:34:01] tickcount - 1140
[21:34:01] GetTickCount - 63167
[21:34:01] tickcount - 1140
[21:34:01] GetTickCount - 63371
[21:34:01] tickcount - 1140
[21:34:01] GetTickCount - 63574
[21:34:01] tickcount - 1140
[21:34:02] GetTickCount - 63779
[21:34:02] tickcount - 1150
[21:34:02] GetTickCount - 63984
[21:34:02] tickcount - 1150
[21:34:02] GetTickCount - 64187
[21:34:02] tickcount - 1150
[21:34:02] GetTickCount - 64390
[21:34:02] tickcount - 1150
[21:34:02] GetTickCount - 64594
[21:34:02] tickcount - 1150
[21:34:03] GetTickCount - 64800
[21:34:03] tickcount - 1150
[21:34:03] GetTickCount - 65004
[21:34:03] tickcount - 1150
[21:34:03] GetTickCount - 65207
[21:34:03] tickcount - 1160
[21:34:03] GetTickCount - 65411
[21:34:03] tickcount - 1160
[21:34:03] GetTickCount - 65614
[21:34:03] tickcount - 1160
[21:34:04] GetTickCount - 65819
[21:34:04] tickcount - 1170
[21:34:04] GetTickCount - 66022
[21:34:04] tickcount - 1170
[21:34:04] GetTickCount - 66225
[21:34:04] tickcount - 1170
Reply
#2

Unix timestamps is what you need, forget GetTickCount and tickcount functions for such things as races.
Reply
#3

GetTickCount and tickcount do not return the same values anyways so that's not something you should worry about.

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Unix timestamps is what you need, forget GetTickCount and tickcount functions for such things as races.
Not really. In races, someone can break a record even for 1 millisecond and that's where the huge competition is. By using seconds only won't be so easy to break a record.
Reply
#4

delete this comment
Reply
#5

just use gettime()
Reply
#6

Quote:
Originally Posted by Kar
Посмотреть сообщение
just use gettime()
gettime doesn't return to milliseconds. I needed accuracy to milliseconds.
gettime() returns in unix timestamp. ( seconds since 1st January 1970)

Although it is weird that these 2 functions work the same on Windows, but do not work @ linux
Reply
#7

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
Although it is weird that these 2 functions work the same on Windows, but do not work @ linux
Granularity, I guess.

From the Pawn documentation:

Quote:
Syntax: tickcount(&granularity=0)

granularity : Upon return, this value contains the number of ticks that the internal system time will tick per second. This value therefore indicates the accuracy of the return value of this function.

Quote:

If the granularity of the system timer is “100” (a typical value for unix systems), the return value will still be in milliseconds, but the value will change only every 10 milliseconds (100 “ticks” per second is 10 milliseconds per tick).

http://www.compuphase.com/pawn/Time_Functions.pdf
https://sampwiki.blast.hk/wiki/Tickcount

Just use GetTickCount if you need an accurate value.
Reply
#8

use GetTickCount, if your server will be up long, make a custom function for 32 bit overflows.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)