def build(self):
end_time = timeit.default_timer()
end_mem = memory_profiler.memory_usage()[0]
sys.stdout = self._previous_stdout
self._log.write("END RequestId: {r}\n".format(
r=self._context.aws_request_id))
duration_in_millis = int(math.ceil(1000 * (end_time - self._start_time)))
# The memory overhead of setting up the AWS Lambda environment
# (when actually run in AWS) is roughly 14 MB
max_memory_used_in_mb = (end_mem - self._start_mem) / 1048576 + 14
self._log.write(
"REPORT RequestId: {r}\tDuration: {d} ms\t"
"Max Memory Used: {m} MB\n"
.format(r=self._context.aws_request_id,
d=duration_in_millis,
m=max_memory_used_in_mb))
log = self._log.getvalue()
return LambdaCallSummary(duration_in_millis, max_memory_used_in_mb, log)
评论列表
文章目录