
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  Sr	S r
S	 rS
 r " S S\R                  5      rg)zFTraffic-specific printer and functions for generating traffic formats.    )absolute_import)division)print_function)unicode_literals)custom_printer_baseprofilec                 X    U R                   nU(       d  SnXR                  S-  -   7nUS $ )z*Converts cost to a decimal representation.r   g    eAz.3f)unitsnanos)costr
   decimal_values      Blib/googlecloudsdk/command_lib/run/printers/profiles_printer_ga.pyamount_to_decimalr      s2    
**%	EJJ,,--#    c                     SnU (       a,  U S   R                   (       a  [        U S   R                   5      nSnU (       a,  U S   R                  (       a  [        U S   R                  5      nX!4$ )zjReturns the cost per million normalized output tokens as a decimal.

Args:
  costs: The costs to convert.
zN/Ar   )costPerMillionOutputTokensr   costPerMillionInputTokens)costsoutput_token_costinput_token_costs      r   get_decimal_costr   %   sf     
uQx22)a++ 
uQx11(q)K)KL
	..r   c                    / SQnU/nU  GH)  n[        UR                  (       a  UR                  S   R                  OS5      u  pEUR                  UR                  UUUR                  S   (       a  UR                  S   R
                  OSUR                  (       a  UR                  S   R                  OSUR                  (       a  UR                  S   R                  OSUR                  R                  UR                  R                  UR                  R                  /
nUR                  U5        GM,     [        R                  " U5      n[        R                  " U/SS9$ )zVTransforms a List[AcceleratorOption] into a table with decimal representation of cost.)
zInstance TypeAcceleratorzCost/M Input TokenszCost/M Output TokenszOutput Tokens/sz	NTPOT(ms)zTTFT(ms)zModel ServerzModel Server VersionModelr   N<   )max_column_width)r   performanceStatsr   instanceTypeacceleratorTypeoutputTokensPerSecondntpotMillisecondsttftMillisecondsmodelServerInfomodelServermodelServerVersionmodelappendcpTableSection)profilesheaderrowspr   r   rowprofiles_tables           r   _transform_profilesr1   6   s(   & $a*:&'&8&81""d+' 	
	a  	
133343E3E1//4232D2D1..$	%%	,,	C 	KK% ( 88D>.	^$r	::r   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )ProfilePrinter`   z=Prints a service's profile in a custom human-readable format.c                 0   > [         [        U ]  USU5        g)z3Overrides ResourcePrinter.Print to set single=True.TN)superr3   Print)self	resourcessingleintermediate	__class__s       r   r7   ProfilePrinter.Printc   s    	.$%i|Dr   c                     [        U5      $ )z@Transforms a List[TrafficTargetPair] into a marker class format.)r1   )r8   r+   s     r   	TransformProfilePrinter.Transformg   s    x((r    )TF)	__name__
__module____qualname____firstlineno____doc__r7   r?   __static_attributes____classcell__)r<   s   @r   r3   r3   `   s    EE) )r   r3   N)rF   
__future__r   r   r   r   googlecloudsdk.core.resourcer   r(   PROFILES_PRINTER_FORMATr   r   r1   CustomPrinterBaser3   rA   r   r   <module>rM      sD    M &  % ' B $  /"';T	)R)) 	)r   