Because you are only taking one sample for each of the iterations of the main while loop, you could add a current timestamp to the data added to the queue. This could be written to file along with the samples and provide a reasonably accurate timestamp for each iteration of the loop.