A1 - Measurement Basics
Start by following the general instructions for assignments to set up your Python environment appropiately.
The first assignment will be a warm up in which you conduct a careful measurement of the costs of basic operations in distributed systems. To that end, write a series of small Python programs that measure the time to do the following things on the student machines:
- Make a trivial function call.
- Create/delete a file in your home directory.
- Create/delete a file in
/tmp
- Get the current wall clock time.
- Insert an item into a Python dictionary.
- Make a TCP connection to a well-known internet service and close it.
- Make an HTTP connection to a well-known website, read back the HTML, and then close it.
- Open a file containing a large JSON document, and parse it into memory. (Check out json-generator.com.)
- Use
scandir
to iterate over all the items in your home directory andstat
each one to measure its size. - Run
ls -l
as a subprocess to accomplish the same thing.
Of course, there is little value in measuring a single one of these items, one of which may be faster than the resolution of the clock. So, measure how long it takes a number of items in a loop, such that the loop takes somewhere between one and three seconds. (You will have to experiment with the proper number of loop iterations for each test, since the times will vary widely.)
Each test program should run without arguments, carry out its measurement silently, and then report the elapsed time, number of operations, average time per operation, fastest single operation, and slowest single operation.
Turning In
Turn in each of your Python programs, naming them Test1.py
, Test2.py
, … corresponding to the numbering above. Also turn in a concise lab report written in plain text called REPORT
that indicates:
- The outputs of each of the tests you ran.
- Which test has the fastest average, the slowest average, and the broadest range of performance.
- Explain the underlying reasons for the performance differences.
See the general instructions for how to turn in your materials.