blob: af53ea514ff44e9890cabcc90eaae942f0d4fb2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
\title{A4: List vs Vector}
\input{preamble.tex}
I wanted to experiment with co-routine generator for the random
numbers but discovered the \texttt{std::generator} is not supplied
with my compiler.
Instead I found what seemed like a similar implementation here:
\texttt{https://en.cppreference.com/w/cpp/language/coroutines}, which
I have copied to the \texttt{generator.h} file for use in my program.
I am aware that the random number generator already kind-of works
similarly to a co-routine generator seen from the outside, so the
whole experiment is a bit pointless from a software design perspective.
For this exercise I also re-designed my measurement tool from the
previous assignments to better support re-use of data across
measurements.
And, finally, I made a class for storing and outputting measurement
points as octave/matlab programs for easier inclusion into the report.
This I put in its own file \texttt{octave.cc} with corresponding
header \texttt{octave.h}. It is by no means very clever, but made to
suit my needs for this assignment.
\bigskip
The random number generation for use in insertion I used the
co-routine as described above, inserting, while checking if the number
already exists.
For the ditto for removal indices, I used
a \texttt{uniform\_distribution} thereby being able to gradually
reduce the span as the container would be expected to shrink 1 in size
for each iteration.
Both random number generators were seeded with the iterator number
(each size is being tested three times) to make sure the three
iterations use unique sets of numbers.
For the smaller sizes of \texttt{N} (the number of items to be
inserted/removed) i print out the numbers to verify their correctness.
\begin{figure}
\includegraphics[scale=0.95]{a4/insert.pdf}
\caption{Insert of int}
\label{insert}
\end{figure}
\begin{figure}
\includegraphics[scale=.95]{a4/remove.pdf}
\caption{Removal of int}
\label{remove}
\end{figure}
\begin{figure}
\includegraphics[scale=0.95]{a4/insert-padded.pdf}
\caption{Insert of padded-int (1024 bytes pr. value)}
\label{insert-padded}
\end{figure}
\begin{figure}
\includegraphics[scale=.95]{a4/remove-padded.pdf}
\caption{Removal of padded-int (1024 bytes pr. value)}
\label{remove-padded}
\end{figure}
\end{document}
|