File: mem-vis.cpp

package info (click to toggle)
seqan3 3.0.2%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,052 kB
  • sloc: cpp: 144,641; makefile: 1,288; ansic: 294; sh: 228; xml: 217; javascript: 50; python: 27; php: 25
file content (83 lines) | stat: -rw-r--r-- 2,647 bytes parent folder | download
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <sdsl/suffix_trees.hpp>
#include <iostream>

using namespace sdsl;
using namespace std;

using namespace std::chrono;
using timer = std::chrono::high_resolution_clock;

int main(int argc, char** argv)
{
    if (argc < 2) {
        cout << "Usage: " << argv[0] << " file" << endl;
        cout << " Creates a CST and CSA for a byte file and visualizes the memory utilization during construction." << endl;
        return 1;
    }

    if(0){
        memory_monitor::start();

        csa_sada<> csa;
        auto start = timer::now();
        construct(csa, argv[1], 1);
        auto stop = timer::now();
        cout << "construction csa time in seconds: " << duration_cast<seconds>(stop-start).count() << endl;

        memory_monitor::stop();
        std::ofstream csaofs("csa-construction_file.html");
        cout << "writing memory usage visualization to csa-construction.html\n";
        memory_monitor::write_memory_log<HTML_FORMAT>(csaofs);
        csaofs.close();
    }

    {
        using csa_t = csa_wt<>;
        //using csa_t = csa_sada<>;

        //read file
        std::string text;
        {
            std::ostringstream ss;
            std::ifstream ifs(argv[1]);
            ss << ifs.rdbuf();
            text = ss.str();
        }

        memory_monitor::start();

        double s = 0;
        int reps = 1;
        auto start = timer::now();
        for (int i=0; i<reps; ++i){
            csa_t csa;
            //construct_im(csa, std::move(text), 1);
            construct_im(csa, text, 1);
            s += csa.size();
            //cout << "size_in_mega_bytes = " << size_in_mega_bytes(csa) << endl;
        }
        auto stop = timer::now();
        cout << "construction csa time in seconds: " << duration_cast<seconds>(stop-start).count() << endl;
        cout << "s = " << s/reps << endl;
        s=0;
        start = timer::now();
        for (int i=0; i<reps; ++i){
            csa_t csa;
            construct(csa, argv[1], 1);
            //cout << "size_in_mega_bytes = " << size_in_mega_bytes(csa) << endl;
            s += csa.size();
        }
        stop = timer::now();
        cout << "construction csa time in seconds: " << duration_cast<seconds>(stop-start).count() << endl;
        cout << "s = " << s/reps << endl;

        
        memory_monitor::stop();
        std::ofstream csaofs("csa-construction_im.html");
        cout << "writing memory usage visualization to csa-construction.html\n";
        memory_monitor::write_memory_log<HTML_FORMAT>(csaofs);
        csaofs.close();
        
    }

}