Lab 13: Experiment 1

Creating New n-Element Containers


Files

The Experiment

For this experiment, the test is to create and (implicitly) initialize list and vector containers:

list<int> theList(n);
vector<int> theVector(n);
All we do is allocate new containers; Perform the test is left empty.

Creating a new container does take time; there's some work involved — perhaps a lot if the container is initialized to some rather large size. Because we'll be creating these containers for the other tests, we want to find out how costly it is to construct an n-element container.

Compile and execute the program on the sample range of n.

Record your results in a spreadsheet and graph them as described in the main lab exercise.

Analysis

To measure the performance of an operation we determine how long it takes for a data set of size n as n changes. We would probably expect that a larger input — i.e., a larger n — will result in execution taking longer. But how much longer? Sometimes n plays no significant role; other times it plays a very important role.

Here are three different categories of performance measures that are used in computing:

There are additional categories (e.g., logarithmic, cubic, exponential, factorial, etc.), but these three are all that we will see in this exercise.

Use these definitions to do some categorization of your results:

Question #13.1.1: How would you categorize the time it takes to create an n-element list? Justify your answer.

Question #13.1.2: How would you categorize the time it takes to create an n-element vector? Justify your answer.

Justification for your categories should describe the graph:


Back to the Lab Exercise  |  Forward to the Next Experiment


Report errors to Larry Nyhoff (nyhl@cs.calvin.edu)