To calculate the average waiting time for level selection, store the history of all selected levels in a file.
Having all history data of level selection also allows the calculation of:
min wait time
max wait time
median wait time (50th percentile)
90th percentile
Store each selected level together with it's level code, waiting time, username, current time, weighted random selection chance, and maybe more information if applicable.
The file to sore that information could be appended by
a newline
a checksum of the JSON data in base64 or hex
a space
the JSON data
When reading the file only valid entries can be read, preventing the file from getting corrupt.
This can be done by reading line by line and checking the following information:
check for the first space per line
split data by that space
calculate checksum of the data right of the space
check with the stored checksum on the left of the space
if the checksum is valid load the JSON data on the right of the space
append the parsed JSON data to a list sorted by waiting time
→ With the sorted list, one can then calculate the stats listed above.
Also sorting is optional just for calculating the average.
To calculate the average waiting time for level selection, store the history of all selected levels in a file. Having all history data of level selection also allows the calculation of:
Store each selected level together with it's level code, waiting time, username, current time, weighted random selection chance, and maybe more information if applicable. The file to sore that information could be appended by
When reading the file only valid entries can be read, preventing the file from getting corrupt. This can be done by reading line by line and checking the following information:
→ With the sorted list, one can then calculate the stats listed above.
Also sorting is optional just for calculating the average.