summaryrefslogtreecommitdiffstats
path: root/benchmarks/tail-latency/btree_tput.cpp
blob: d091ff59e0cfd786d9f925b15764e2f50a122580 (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
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
/*
 *
 */

#define ENABLE_TIMER

#include "shard/ISAMTree.h"
#include "query/rangequery.h"
#include "framework/interface/Record.h"
#include "file_util.h"
#include "benchmark_types.h"

#include <gsl/gsl_rng.h>

#include "psu-util/timer.h"
#include "standard_benchmarks.h"
#include "psu-ds/BTree.h"

typedef btree_record<int64_t, int64_t> Rec;

typedef de::ISAMTree<Rec> Shard;
typedef de::irs::Query<Shard> Q;
typedef Q::Parameters QP;

void usage(char *progname) {
    fprintf(stderr, "%s reccnt datafile queryfile\n", progname);
}

int main(int argc, char **argv) {

    if (argc < 4) {
        usage(argv[0]);
        exit(EXIT_FAILURE);
    }

    size_t n = atol(argv[1]);
    std::string d_fname = std::string(argv[2]);
    std::string q_fname = std::string(argv[3]);

    auto btree = BenchBTree();
    
    auto data = read_sosd_file<Rec>(d_fname, n);

    /* read in the range queries and add sample size and rng for sampling */
    auto queries = read_range_queries<QP>(q_fname, .0001);

    /* warmup structure w/ 10% of records */
    size_t warmup = .3 * n;
    for (size_t i=0; i<warmup; i++) {
        btree.insert(data[i]);
    }

    TIMER_INIT();
    /* insertion benchmark */
    TIMER_START();
    for (size_t i=warmup; i<data.size(); i++) {
        btree.insert(data[i]);
    }
    TIMER_STOP();

    size_t insert_tput =
        ((double)(n - warmup) / (double)TIMER_RESULT()) * 1e9;

    fprintf(stdout, "%ld\n", insert_tput);

    // /* run queries */
    // TIMER_START();
    // size_t total = 0;
    // for (size_t j=0; j<10; j++) {
    //     for (size_t i=0; i<queries.size(); i++) {
    //         total += btree.range_count(queries[i].lower_bound, queries[i].upper_bound);
    //     }
    // }
    // TIMER_STOP();

    // fprintf(stderr, "%ld\n", total);
}