def calculate_cost(avg_duration, sum_invocations, memory_size): """ Calculate cost based on AWS Lambda pricing. :param avg_duration: Avg. duration of function. :param sum_invocations: Count of invocations of function. :param memory_size: Function's memory size. :return: cost. """ return ((avg_duration / PRICE_INTERVALS_MS) * sum_invocations * get_price_by_memory(memory_size) + sum_invocations * PRICE_PER_INVOCATION)
def calculate_cost(avg_duration, sum_invocations, memory_size): """ Calculate cost based on AWS Lambda pricing. :param avg_duration: Avg. duration of function. :param sum_invocations: Count of invocations of function. :param memory_size: Function's memory size. :return: cost. """ #price = get_price_by_memory(memory_size) #print(f"{avg_duration}, {sum_invocations}, {memory_size}, {price}") print( f"{ceil(avg_duration / PRICE_INTERVALS_MS)*(get_price_by_memory(memory_size))}" ) print(f"Sum is {(sum_invocations * PRICE_PER_INVOCATION)}") value1 = ceil( avg_duration / PRICE_INTERVALS_MS) * (get_price_by_memory(memory_size)) value2 = sum_invocations * PRICE_PER_INVOCATION value3 = value1 + value2 print(f"Total value is {value3}") return value3