r2u2_cli 4.1.0

R2U2 CLI: A stream-based runtime monitor command-line interface
�

`ɭh�	��h�SSKrSSKrSSKJr SrS\S\4SjrS\4Sjr	S\SS4Sjr
S\SS4S	jrg)
�N)�log�UTIL�bytes�returnc�x�US:aUS3$US:a	US-SS3$US:aUS-S-SS3$US-S-S-SS3$)	z<Return the given number of bytes in a human-readable format.�z bytesiz.2fz KBi@z MBz GB��rs �h/Users/aaurandt/Desktop/IowaState/R2U2Research/Dissertation/Comparison/r2u2-modify/compiler/c2po/util.py�format_bytesr	sr���t�|������	��	��$�,�s�#�3�'�'�	�#�	#��$�,��%�c�*�#�.�.��$�,��%��,�S�1��5�5�c���[R"[R5n[R"[R5nURUR-UR
-UR
-$)z�Returns sum of user and system mode times for the current and child processes in seconds. See https://docs.python.org/3/library/resource.html.)�resource�	getrusage�RUSAGE_SELF�RUSAGE_CHILDREN�ru_utime�ru_stime)�rusage_self�rusage_childs  r�get_rusage_timersh���$�$�X�%9�%9�:�K��%�%�h�&>�&>�?�L����
�
�
�	 �
�
�
�	��
�
�	 �r
c���[RS:Xa[R"[SS5 g[R"[SS[U535 [R"[RU[R45 g![a [R"[S5 g[a [R"[S5 gf=f)z Set the maximum memory in bytes.�darwin�zImacOS does not support setrlimit for RLIMIT_AS, ignoring max memory limitNzSetting max memory to zFailed to set max memory limit, provided limit is likely over current hard limit or OS does not support setrlimit for RLIMIT_AS)
�sys�platformr�debug�MODULE_CODErr�	setrlimit�	RLIMIT_AS�
RLIM_INFINITY�
ValueError�warning�
OverflowErrorr
s r�set_max_memoryr%!s���
�|�|�x���	�	��
�W�	
�
	��I�I�k�1� 6�|�E�7J�6K�L�M�
����8�-�-��x�7M�7M�/N�O���
�����
N�	
��
�����
N�	
�
�s�5B�%C�8$C�Cc	�z�US::ag[R"[R5n[R"[R5nURUR-n[
RS:XaUS-n[R"[SS[US-535 X-n[U5 g)ztSet the maximum memory in bytes, offset by the current memory usage. Does nothing if the offset is zero or negative.rNrrrzCurrent memory usage: )rrrr�	ru_maxrssrrrrrrr%)rrr�current_memory�
new_memorys     r�set_max_memory_offsetr*;s�����z���$�$�X�%9�%9�:�K��%�%�h�&>�&>�?�L� �*�*�\�-C�-C�C�N�
�|�|�x��'�4�/���I�I�k�1� 6�|�N�UY�DY�7Z�6[�\�]��'�J��:�r
)rr�c2porr�int�strr�floatrr%r*r	r
r�<module>r/sX���
����	6��	6��	6�	��	�
�#�
�$�
�4����r