Repository navigation
Fix format_duration() truncating each timestamp before subtracting - #3536
Merged
cyberw merged 1 commit intoOct 3, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
format_duration()truncated both operands before subtracting them, so the fractional part is lost twice:int(1700000002.1) - int(1700000000.9)is2although only 1.2 s elapsed.get_html_report()feeds itstats.start_timeandstats.last_request_timestamp(locust/html.py:99), so the duration in the HTML report is a whole second too long wheneverstart_timehas the larger fractional part, and two runs of identical length can be displayed differently depending on where the whole-second boundary falls.This commit truncates once, on the difference. Inputs that already are whole seconds format exactly as before, so the values in the existing
dates_checkstable are unchanged.Fixes #3535
How was it checked
On
masteratc6c51480, with the new test parametrization added and the source line untouched (baseline):after the one-line change:
locust/test/test_web.py -k "report or duration or timestamp"gives7 failed, 1 passedboth before and after this change on this Windows machine (pre-existingGET /stats/report500s because the built web UI assets are missing locally), so no difference is introduced there.Drafted with AI assistance in this session; no human reviewed it before submission.