Skip to content

Commit 1e8bb68

Browse files
committed
added execution time
1 parent 47a5b95 commit 1e8bb68

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ Next let's open ``service.py``, in here you'll find the following function:
6767
# You code goes here!
6868
e = event.get('e')
6969
pi = event.get('pi')
70-
print "your test handler was successfully invoked!"
7170
return e + pi
7271
7372
@@ -82,10 +81,10 @@ If you now try and run:
8281
.. code:: bash
8382
8483
(lambduh) $ lambda invoke
85-
# "your test handler was successfully invoked!"
86-
# below shows the result returned by your function execution:
8784
# 5.858
8885
86+
# your code completed in: 0.00000310s
87+
8988
As you probably put together, the ``lambda invoke`` command grabs the values stored in the ``event.json`` file and passes them to your function.
9089

9190
The ``event.json`` file should help you develop your Lambda service locally. You can specify an alternate ``event.json`` file by passing the ``--event-file=<filename>.json`` argument to ``lambda invoke``.

aws_lambda/aws_lambda.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import print_function
33
import json
4-
import os
54
import logging
5+
import os
6+
import time
67
from imp import load_source
78
from shutil import copy, copyfile
89
from tempfile import mkdtemp
@@ -77,9 +78,12 @@ def invoke(src, alt_event=None):
7778

7879
# TODO: look into mocking the ``context`` variable, currently being passed
7980
# as None.
81+
start = time.time()
8082
results = fn(event, None)
81-
print("below shows the result returned by your function "
82-
"execution:\n{0}".format(results))
83+
end = time.time()
84+
elapsed = end - start
85+
print("{0}".format(results))
86+
print("\nyour code completed in: {:.8f}s".format(elapsed))
8387

8488

8589
def init(src, minimal=False):

aws_lambda/project_template/service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ def handler(event, context):
55
# You code goes here!
66
e = event.get('e')
77
pi = event.get('pi')
8-
print "your test handler was successfully invoked!"
98
return e + pi

0 commit comments

Comments
 (0)