mCRL2
Loading...
Searching...
No Matches
progress_meter.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_UTILITIES_PROGRESS_METER_H
13#define MCRL2_UTILITIES_PROGRESS_METER_H
14
15#include <cstddef>
17
18namespace mcrl2 {
19
20namespace utilities {
21
24{
25 protected:
26 std::size_t n;
27 std::size_t N;
28
29 public:
31 progress_meter(std::size_t N_ = 0)
32 : n(0), N(N_)
33 {}
34
36 void set_size(std::size_t N_)
37 {
38 N = N_;
39 }
40
42 void step()
43 {
44 n++;
45 if (N < 1000 || (n % (N / 1000) == 0) || n == N)
46 {
47 std::size_t percentage = 1000 * n / N;
48 mCRL2log(log::status) << (percentage / 10) << "." << (percentage % 10) << " percent completed" << std::endl;
49 }
50 }
51};
52
53} // namespace utilities
54
55} // namespace mcrl2
56
57#endif // MCRL2_UTILITIES_PROGRESS_METER_H
#define percentage(steps, total)
Displays progress messages for a task that performs a fixed number of steps.
void step()
Should be called after every step. Regularly a message is printed to log::status.
void set_size(std::size_t N_)
Set the number of steps of the task.
progress_meter(std::size_t N_=0)
Constructor.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72