There's two parts needed to answer this question. Firstly, the commonly used timer program LiveSplit supports automatic time splitting. It needs to be configured on a game-by-game basis via image/audio recognition or reading memory for PC games and emulated games. In the case of SMB1, auto splitters are available.
Secondly, video game speedrun records are typically tracked by speedrun.com. For a player to have their speedrun record recognized, they will need to submit their run for review. Moderators do not solely rely on a streamer's live timer. When moderators "retime" a run after the fact, it's common that the actual time may differ from what's shown on the timer. (See also this SMB1 retiming tool)
For reference, Speedrun.com's Super Mario Bros 1 leaderboards have specific rules on how runs are timed. (Specific sections bolded for emphasis)
Goal
Beat the game as fast as possible by any means necessary.
Timing
Timing is done using the SDA standard:
Start - The frame "400" appears in the top right corner after selecting 1 player.
End - The frame all sprites are invisible after touching the axe in 8-4.
Category Rules
- Using save states to the title screen is prohibited. You must use the reset function on your emulator or console and the reset must be shown in the video.
- Only runs faster than 5:03 (5:08 for PAL) are represented with milliseconds on the leaderboard. Please do not include milliseconds if your time is not below this threshold.
- It is recommended to hold onto full session, split files, input files, etc. in the event that a moderator requests additional evidence for verification.
Times below 4:57.000 are treated with additional scrutiny. The following is required for submissions below this threshold:
- The run's full session must be included in the submission's description. Additional attempt sessions may be requested at the discretion of the moderation team.
- For emulator submissions, the run must have an input display visible at all times. A hand-cam or input visualizer program is sufficient for emulators without a built-in input display.