Ë
    æØjj|  ã                  ó.  — d Z ddlmZ ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	l	m
Z
 e
rdd
lmZ  ej                  d¬«       G d„ d«      «       Z ej                  d¬«       G d„ d«      «       Zej                   G d„ d«      «       Zg d¢Zy)zøIndirection for time functions.

We intentionally grab some "time" functions internally to avoid tests mocking "time" to affect
pytest runtime information (issue #185).

Fixture "mock_timing" also interacts with this module for pytest's own tests.
é    )ÚannotationsN)Údatetime)Útimezone©Úperf_counter)Úsleep©Útime)ÚTYPE_CHECKING)ÚMonkeyPatchT)Úfrozenc                  óŠ   — e Zd ZU dZ ej
                  d„ d¬«      Zded<    ej
                  d„ d¬«      Zded<   dd	„Z	dd
„Z
y)ÚInstantz«
    Represents an instant in time, used to both get the timestamp value and to measure
    the duration of a time span.

    Inspired by Rust's `std::time::Instant`.
    c                 ó   — t        «       S ©Nr	   © ó    úP/opt/eval-harness/bench_task/venv/lib/python3.12/site-packages/_pytest/timing.pyú<lambda>zInstant.<lambda>$   s   € ¼D»F€ r   F)Údefault_factoryÚinitÚfloatr
   c                 ó   — t        «       S r   r   r   r   r   r   zInstant.<lambda>)   s   € ¤£€ r   Ú
perf_countc                ó,   — t        | t        «       ¬«      S )z1Measure the duration since `Instant` was created.)ÚstartÚstop)ÚDurationr   ©Úselfs    r   ÚelapsedzInstant.elapsed-   s   € ä˜d¬«Ô3Ð3r   c                ó^   — t        j                  | j                  t        j                  «      S )zInstant as UTC datetime.)r   Úfromtimestampr
   r   Úutcr   s    r   Úas_utczInstant.as_utc1   s   € ä×%Ñ% d§i¡i´·±Ó>Ð>r   N)Úreturnr   )r&   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚdataclassesÚfieldr
   Ú__annotations__r   r!   r%   r   r   r   r   r      sM   … ñð $�+×#Ñ#±NÈÔO€Dˆ%ÓOð *˜×)Ñ)Ù.Øô€J�ó ó
4ô?r   r   c                  ó8   — e Zd ZU dZded<   ded<   edd„«       Zy)r   z2A span of time as measured by `Instant.elapsed()`.r   r   r   c                ó\   — | j                   j                  | j                  j                  z
  S )zaElapsed time of the duration in seconds, measured using a performance counter for precise timing.)r   r   r   r   s    r   ÚsecondszDuration.seconds=   s#   € ð �y‰y×#Ñ# d§j¡j×&;Ñ&;Ñ;Ð;r   N©r&   r   )r'   r(   r)   r*   r-   Úpropertyr0   r   r   r   r   r   6   s!   … á<àƒNØ
ƒMàò<ó ñ<r   r   c                  ój   — e Zd ZU dZ edddddd«      j                  «       Zded	<   dd
„Zdd„Z	dd„Z
y)Ú
MockTiminga  Mocks _pytest.timing with a known object that can be used to control timing in tests
    deterministically.

    pytest itself should always use functions from `_pytest.timing` instead of `time` directly.

    This then allows us more control over time during testing, if testing code also
    uses `_pytest.timing` functions.

    Time is static, and only advances through `sleep` calls, thus tests might sleep over large
    numbers and obtain accurate time() calls at the end, making tests reliable and instant.iä  é   é   é   é   é2   r   Ú_current_timec                ó.   — | xj                   |z  c_         y r   ©r:   )r    r0   s     r   r   zMockTiming.sleepR   s   € Ø×Ò˜gÑ%Ör   c                ó   — | j                   S r   r<   r   s    r   r
   zMockTiming.timeU   s   € Ø×!Ñ!Ð!r   c                ó¾   — ddl m} |j                  |d| j                  «       |j                  |d| j                  «       |j                  |d| j                  «       y )Nr   )Útimingr   r
   r   )Ú_pytestr?   Úsetattrr   r
   )r    Úmonkeypatchr?   s      r   ÚpatchzMockTiming.patchX   sG   € å"à×Ñ˜F G¨T¯Z©ZÔ8Ø×Ñ˜F F¨D¯I©IÔ6Ø×Ñ˜F N°D·I±IÕ>r   N)r0   r   r&   ÚNoner1   )rB   r   r&   rD   )r'   r(   r)   r*   r   Ú	timestampr:   r-   r   r
   rC   r   r   r   r4   r4   C   s;   … ñ	_ñ $ D¨!¨R°°R¸Ó<×FÑFÓH€M�5ÓHó&ó"ô?r   r4   )r   r   r
   )r*   Ú
__future__r   r+   r   r   r
   r   r   Útypingr   Úpytestr   Ú	dataclassr   r   r4   Ú__all__r   r   r   ú<module>rK      sž   ðñõ #ã Ý Ý Ý Ý Ý Ý  ñ Ý"ð €×Ñ˜dÔ#÷?ð ?ó $ð?ð: €×Ñ˜dÔ#÷	<ð 	<ó $ð	<ð ×Ñ÷?ð ?ó ð?ò: ,�r   