Records timing information for a server resource. :param name: The name of the resource. :type name: string :param duration: The time in seconds to report. Internally, this is rounded to the nearest millisecond. :type duration: float :param desc
(name, duration, description=None)
| 214 | @staticmethod |
| 215 | @has_context |
| 216 | def record_timing(name, duration, description=None): |
| 217 | """Records timing information for a server resource. |
| 218 | |
| 219 | :param name: The name of the resource. |
| 220 | :type name: string |
| 221 | |
| 222 | :param duration: The time in seconds to report. Internally, this |
| 223 | is rounded to the nearest millisecond. |
| 224 | :type duration: float |
| 225 | |
| 226 | :param description: A description of the resource. |
| 227 | :type description: string or None |
| 228 | """ |
| 229 | request = get_app().backend.request_adapter() |
| 230 | timing_information = getattr(request.context, "timing_information", {}) |
| 231 | |
| 232 | if name in timing_information: |
| 233 | raise KeyError(f'Duplicate resource name "{name}" found.') |
| 234 | |
| 235 | timing_information[name] = {"dur": round(duration * 1000), "desc": description} |
| 236 | |
| 237 | setattr(request.context, "timing_information", timing_information) |
| 238 | |
| 239 | @property |
| 240 | @has_context |