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',
]

Configuration

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 版本加入.