Improved precision of timeit #3185
Merged
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.
The variance of the returned timing is reduced.
Now the median of multiple measures is returned in stead of the mean, so that outliers have less impact on the result.
The function also runs for at least 3 consecutive times (or 50ms), giving the possibility to measure the overlapping between CPU and GPU. This can result in lower, although more correct readings, especially for fast functions.
Description
When measuring an empty function {}, the returned timing was 1/700 lower (1.2ps vs 800ps). This is, because the number of cycles is automatically increased to obtain 50ms for each measure.
For slow functions, at least 3 cycles are used for the measure.
In total 0.5s is the typical total time for the function to return.
The variance has now become small enough, so that also faster functions can be compared on speed progress.
A comparison, between old and new, on af::constant() can be found in timeit.xlsx
Changes to Users
The returned time will be of higher quality.
Checklist