I need advice on file i/o at bare minimum overhead (sub-millisecond to be more precise). (App design suggestion/crates/ -- What kind of file I should use? Any crates for this? etc)
I know this question is opinion-based but I want to hear good opinions.
Part of my project requires me to have a persistent stop-watch. Thinking of different approaches of creating a persistent stopwatch. What I'm thinking is, whenever a user starts a stopwatch:
- App creates a file somewhere in $HOME
- Whenever there's a "lap", that time will be written in that file in a new line
This way, even if the app crashes or system shuts down, the stopwatch will keep "running". When the user comes back to the computer and runs the app and opens the stopwatch window, he'll see that the stop watch is still running, as the window keeps calculating the time difference in each millisecond.
- When the user presses the reset button, the app will remove that stopwatch file
Thus you achieve truly persistent stopwatch.
As you can see, I have to read a file and parse the strings within a very low time. Is there any better approach for keeping track of time instances?