Antares Simulator
Power System Simulator
DurationCollector.h
1
/*
2
** Copyright 2007-2025, RTE (https://www.rte-france.com)
3
** See AUTHORS.txt
4
** SPDX-License-Identifier: MPL-2.0
5
** This file is part of Antares-Simulator,
6
** Adequacy and Performance assessment for interconnected energy networks.
7
**
8
** Antares_Simulator is free software: you can redistribute it and/or modify
9
** it under the terms of the Mozilla Public Licence 2.0 as published by
10
** the Mozilla Foundation, either version 2 of the License, or
11
** (at your option) any later version.
12
**
13
** Antares_Simulator is distributed in the hope that it will be useful,
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
** Mozilla Public Licence 2.0 for more details.
17
**
18
** You should have received a copy of the Mozilla Public Licence 2.0
19
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20
*/
21
#pragma once
22
23
#include <chrono>
24
#include <functional>
25
#include <map>
26
#include <mutex>
27
#include <string>
28
#include <vector>
29
30
#include "file_content.h"
31
32
namespace
Benchmarking
33
{
34
35
class
DurationCollector
final
36
{
37
public
:
38
void
toFileContent(
FileContent
& file_content);
39
40
struct
OperationTimer
41
{
42
OperationTimer
(
DurationCollector
& collector,
const
std::string& key):
43
collector(collector),
44
key(key)
45
{
46
}
47
48
void
addDuration(int64_t duration_ms)
const
;
49
50
DurationCollector
& collector;
51
const
std::string key;
52
};
53
54
OperationTimer
operator()(
const
std::string& key);
55
56
friend
void
operator<<(
const
OperationTimer
& op,
const
std::function<
void
(
void
)>& f);
57
58
int64_t getTime(
const
std::string& name)
const
;
59
60
private
:
61
std::map<std::string, std::vector<int64_t>> duration_items_;
62
63
// Durations can be added in a context of multi-threading, so we need to protect
64
// these additions from thread concurrency
65
std::mutex mutex_;
66
};
67
68
}
// namespace Benchmarking
Benchmarking::DurationCollector
Definition:
DurationCollector.h:36
Benchmarking::FileContent
Definition:
file_content.h:30
Benchmarking::DurationCollector::OperationTimer
Definition:
DurationCollector.h:41
src
libs
antares
benchmarking
include
antares
benchmarking
DurationCollector.h
Generated by
1.9.1