aboutsummaryrefslogtreecommitdiff
path: root/mem_stdvec.cpp
blob: e0182a3728d114ada4142179e41e4b89c58fe8dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
}