aboutsummaryrefslogtreecommitdiff
path: root/src/common/timings.h
blob: 6e7ff565981fe1fd745d97a68e7035ff702dc697 (plain) (blame)
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
#pragma once

#include <stdint.h>
#include <string>
#include <utility>
#include <vector>

class TimingsDatabase
{
public:
  struct instance
  {
    time_t t;
    size_t npoints;
    double min, max, mean, median, stddev, npskew;
    std::vector<uint64_t> deciles;
  };

public:
  TimingsDatabase();
  TimingsDatabase(const std::string &filename, const bool load_previous = false);
  ~TimingsDatabase();

  const instance* get_most_recent(const char *name) const;
  void add(const char *name, const instance &data);
  bool save(const bool print_current_time = true);

private:
  bool load();

private:
  std::string filename;
  std::vector<std::pair<std::string, instance>> instances;
};