aboutsummaryrefslogtreecommitdiff
path: root/mem_stdvec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mem_stdvec.cpp')
-rwxr-xr-xmem_stdvec.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/mem_stdvec.cpp b/mem_stdvec.cpp
new file mode 100755
index 0000000..e0182a3
--- /dev/null
+++ b/mem_stdvec.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <vector>
+
+#include "antioptimise.h"
+#include "pal.h"
+
+// LOOP_ITERS_NO is defined on the command line.
+static constexpr size_t kLoopItersNo = LOOP_ITERS_NO;
+
+DECL_MAIN {
+ size_t n = kLoopItersNo;
+ PhantomWrite(n);
+
+ std::vector<int> a;
+ for (size_t i = 0; i < n; i++) {
+ a.push_back(static_cast<int>(i));
+ }
+
+ PhantomRead(a);
+
+ std::cout << "Peak memory use: " << pal::GetPeakMemoryUse() << std::endl;
+}