aboutsummaryrefslogtreecommitdiff
path: root/mem_dynarray.cpp
blob: d937175a8fd6a06e9fca39441a897422c346535c (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
#include <iostream>

#include "antioptimise.h"
#include "dynarray.h"

// LOOP_ITERS_NO is defined on the command line.
static constexpr size_t kLoopItersNo = LOOP_ITERS_NO;

DECL_MAIN {
    size_t n = kLoopItersNo;
    static constexpr size_t N = 16ULL * 1024ULL * 1024ULL * 1024ULL;
    assert(n <= N);
    
    PhantomWrite(n);

    auto a = DynArray<int>(N);
    for (size_t i = 0; i < n; i++) {
        a.Append(static_cast<int>(i));
    }

    PhantomRead(a);

    std::cout << "Peak memory use: " << pal::GetPeakMemoryUse() << std::endl;
}