about summary refs log tree commit diff homepage
path: root/include/klee/Statistics/TimerStatIncrementer.h
blob: 90d1ba7d5e8d41c2f0e52fcb67007032e18f7967 (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
35
36
37
//===-- TimerStatIncrementer.h ----------------------------------*- C++ -*-===//
//
//                     The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef KLEE_TIMERSTATINCREMENTER_H
#define KLEE_TIMERSTATINCREMENTER_H

#include "klee/Statistics/Statistics.h"
#include "klee/Support/Timer.h"

namespace klee {

  /**
   * A TimerStatIncrementer adds its lifetime to a specified Statistic.
   */
  class TimerStatIncrementer {
  private:
    const WallTimer timer;
    Statistic &statistic;

  public:
    explicit TimerStatIncrementer(Statistic &statistic) : statistic(statistic) {}
    ~TimerStatIncrementer() {
      // record microseconds
      statistic += timer.delta().toMicroseconds();
    }

    time::Span delta() const { return timer.delta(); }
  };
}

#endif /* KLEE_TIMERSTATINCREMENTER_H */