a
    ¦ˆcþ  ã                   @   sh  d Z ddlZddlZddlmZ ddlmZmZmZm	Z	 dZ
dZdZdZee
ƒD ]Zeejed	�ƒ qPeƒ ZeeƒD ]Zed
jed	�ƒ qtdZee
ƒD ]$ZeeƒD ]Zeejeed�ƒ q¢q–eƒ ZdZee
ƒD ](ZeeeƒƒD ]Zeejeed�ƒ qÞqÎe ¡ ZeeƒD ]Ze ee¡ �qe ¡ e eeƒ d Ze de ƒ ee
ƒD ]6Zedjed	�ƒ edjed	�ƒ edjed	�ƒ �qHe!ƒ ZeeƒD ]Zedjed	�ƒ �qŽdZ"ee
ƒD ](ZeeƒD ]Zee"jeed�ƒ �q¾�q²eƒ ZdZ#ee
ƒD ],ZeeeƒƒD ]Zee#jeed�ƒ �qþ�qîe ¡ ZeeƒD ]Ze ee$¡ �q,e ¡ e eeƒ d Ze de ƒ dS )z¿ Simple benchmarking of the adaptation manager.

This is not 'enforced' by any tests (i.e. we currently aren't bound to satisfy
any performance criteria - but in the future we might be ;^).

é    N)ÚAdaptationManager)ÚAdapterÚ	HasTraitsÚ	InterfaceÚprovidesé   éd   é2   zZ
class IFoo{i}(Interface):
    pass

@provides(IFoo{i})
class Foo{i}(HasTraits):
    pass
)Úizclass I{i}(Interface): passzG
@provides(I{target})
class IFoo{source}ToI{target}(Adapter):
    pass
)ÚsourceÚtargetz—

adaptation_manager.register_factory(
    factory       = IFoo{source}ToI{target},
    from_protocol = IFoo{source},
    to_protocol   = I{target}
)

g     @�@z2apptools using Interfaces: %.3f msec per iterationz$
class FooABC{i}(abc.ABC):
    pass
zclass Foo{i}(object): passzFooABC{i}.register(Foo{i})z!
class ABC{i}(abc.ABC):
    pass
z�
class FooABC{source}ToABC{target}(object):
    def __init__(self, adaptee):
        pass

ABC{target}.register(FooABC{source}ToABC{target})
z�
adaptation_manager.register_factory(
    factory       = FooABC{source}ToABC{target},
    from_protocol = FooABC{source},
    to_protocol   = ABC{target}
)
z,apptools using ABCs: %.3f msec per iteration)%Ú__doc__ÚabcÚtimeZ$traits.adaptation.adaptation_managerr   Z
traits.apir   r   r   r   Z	N_SOURCESZN_ITERATIONSZN_PROTOCOLSZcreate_classes_to_adaptÚranger
   ÚexecÚformatZFoo1ZfooZcreate_traits_adapter_classr   r   Zadaptation_managerZregister_ifoox_to_ixÚreversedÚ
start_timeÚ_ZadaptZI0ÚfloatZtime_per_iterÚprintZFoo0Zcreate_abc_adapter_classZregister_fooxabc_to_abcxZABC0© r   r   úd/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traits/adaptation/tests/benchmark.pyÚ<module>   sp   üÿüÿ
