sphinx.ext.duration -- Measure durations of Sphinx processing

在 2.4 版被加入.

This extension measures durations of Sphinx processing when reading documents and is useful for inspecting what document is slowly built. Durations are printed to console at the end of the build and saved to a JSON file in the output directory by default.

Enable this extension by adding 'sphinx.ext.duration' to the extensions list in your conf.py:

extensions = [
    ...
    'sphinx.ext.duration',
]

組態

duration_print_total
型別:
bool
預設值:
True

Show the total reading duration in the build summary, e.g.:

====================== total reading duration ==========================
Total time reading 31 files: 0m 3.142s

在 9.0 版被加入.

duration_print_slowest
型別:
bool
預設值:
True

Show the slowest durations in the build summary. The durations are sorted in order from slowest to fastest. This prints up to duration_n_slowest durations, e.g.:

====================== slowest 5 reading durations =======================
0.012s spam
0.011s ham
0.011s eggs
0.006s lobster
0.005s beans

在 9.0 版被加入.

duration_n_slowest
型別:
int
預設值:
5

Maximum number of slowest durations to show in the build summary when duration_print_slowest is enabled. By default, only the 5 slowest durations are shown. Set this to 0 to show all durations.

在 9.0 版被加入.

duration_write_json
型別:
str | None
預設值:
'sphinx-reading-durations.json'

Write all reading durations to a JSON file in the output directory The file contents are a map of the document names to reading durations, where document names are strings and durations are floats in seconds. Set this value to an empty string or None to disable writing the file, or set it to a relative path to customize it.

This may be useful for testing and setting a limit on reading times.

在 9.0 版被加入.

duration_limit
型別:
float | int | None
預設值:
None

Set a duration limit (in seconds) for reading a document. If any duration exceeds this value, a warning is emitted.

在 9.0 版被加入.