�
tzi�5 � � � d Z ddlZddlmc mZ ddlZddlZddl m
Z
mZmZ G d� d� � Z
G d� d� � Z G d� d � � Z G d
� d� � Z G d� d
� � Z G d� d� � Zedk r ej eddg� � dS dS )a) Performance tests for Python pattern-core bindings.
Tests that Python bindings maintain performance within 2x of native Rust operations.
Note: These are basic performance tests to verify the bindings don't introduce
catastrophic overhead. Detailed benchmarks should be run with dedicated tools.
� N)�Pattern�PatternSubject�Subjectc �$ � e Zd ZdZd� Zd� Zd� ZdS )�TestConstructionPerformancez&Test pattern construction performance.c �. � d}t j � � }t |� � D ]}t j |� � }�t j � � |z
}d}||k }|s�t j d|fd||f� � dt
j � � v st j |� � rt j |� � ndt j |� � d�z }dd|iz } t t j | � � � � �d x}}t d
|� d|d�d
||z d�d�� � d S )z8Creating many atomic patterns should be reasonably fast.�� � �?��<�z%(py0)s < %(py3)s�elapsed��py0�py3�assert %(py5)s�py5Nz
Point creation: �
patterns in �.4f�s (�.1f� ops/sec))
�time�ranger �point�
@pytest_ar�_call_reprcompare�@py_builtins�locals�_should_repr_global_name� _saferepr�AssertionError�_format_explanation�print�
�self�
iterations�start�i�_r �@py_assert2�@py_assert1�@py_format4�@py_format6s
�b/Users/akollegger/Developer/gram-data/gram-rs/crates/pattern-core/tests/python/test_performance.py�test_point_creation_performancez;TestConstructionPerformance.test_point_creation_performance sI � ��
�� �����z�"�"� !� !�A��
�a� � �A�A��)�+�+��%�� ��w��}����������w��������������w������w���������������������������������
�m�:�m�m�G�m�m�m�J�W^�L^�m�m�m�m�n�n�n�n�n� c �~ � d}t j � � }t |� � D ]>}t j |� � }t d� � D ]}t j ||g� � }��?t j � � |z
}d}||k }|s�t j d|fd||f� � dt j � � v st j |� � rt j
|� � ndt j
|� � d�z } dd | iz }
t t j |
� � � � �d
x}}t d|� d|d
�d||z d�d�� � d
S )z3Creating nested patterns should be reasonably fast.�d �
� @r r
r r r r Nz
Nested pattern creation: r r r r r )r r r r �patternr r r r r r! r"