File: allocator.cpp

package info (click to toggle)
seqan2 2.4.0%2Bdfsg-8~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 223,616 kB
  • sloc: cpp: 256,884; ansic: 91,671; python: 8,339; sh: 995; xml: 570; makefile: 242; awk: 51
file content (41 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download | duplicates (7)
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
//![definitions]
#include <iostream>
#include <seqan/basic.h>

using namespace seqan;

int main()
{
    Allocator<MultiPool<> > mpa;
    Allocator<SimpleAlloc<> > sa;
    // store blocksizes in an array
    int bs[3] = {10, 100, 1000};
    int runs = 100000;
    char * buf;
    double startTime;
//![definitions]
//![time-measurements]

    // loop through the different block sizes
    for (int i = 0; i < 3; ++i)
    {
        startTime = sysTime();
        for (int j = 0; j < runs; ++j)
            allocate(mpa, buf, bs[i], TagAllocateTemp());
        clear(mpa);

        std::cout << "Allocating and clearing " << runs << " times blocks of size ";
        std::cout << bs[i] << " with MultiPool Allocator took " << sysTime() - startTime << std::endl;

        startTime = sysTime();
        for (int j = 0; j < runs; ++j)
            allocate(sa, buf, bs[i], TagAllocateTemp());
        clear(sa);

        std::cout << "Allocating and clearing " << runs << " times blocks of size ";
        std::cout << bs[i] << " with Standard Allocator took " << sysTime() - startTime << std::endl;
    }

    return 0;
}
//![time-measurements]