Skip to content

Commit

Permalink
Improved in-code documentation (mostly alignments).
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuehlig committed Dec 4, 2024
1 parent 7aef250 commit 2f19f0b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 55 deletions.
1 change: 0 additions & 1 deletion include/perfcpp/analyzer/memory_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ class MemoryAccess
* Finds a registered data type with the given name.
*
* @param data_type_name Name of the data type to lookup.
*
* @return Iterator of the data type.
*/
std::vector<std::pair<DataType, std::unordered_map<std::string, std::vector<std::uintptr_t>>>>::iterator find(
Expand Down
25 changes: 6 additions & 19 deletions include/perfcpp/counter_definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CounterDefinition
*/
void add(std::string&& name, CounterConfig config)
{
_counter_configs.insert(std::make_pair(std::move(name), config));
_hardware_counter_configurations.insert(std::make_pair(std::move(name), config));
}

/**
Expand Down Expand Up @@ -106,7 +106,6 @@ class CounterDefinition
* Checks if a specific counter is registered and returns the name and the config.
*
* @param name Name of the queried counter.
*
* @return Name and config of the counter, std::nullopt of the counter does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, CounterConfig>> counter(std::string&& name) const noexcept
Expand All @@ -118,7 +117,6 @@ class CounterDefinition
* Checks if a specific counter is registered and returns the name and the config.
*
* @param name Name of the queried counter.
*
* @return Name and config of the counter, std::nullopt of the counter does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, CounterConfig>> counter(
Expand All @@ -128,7 +126,6 @@ class CounterDefinition
* Checks if a specific counter is registered and returns the name and the config.
*
* @param name Name of the queried counter.
*
* @return Name and config of the counter, std::nullopt of the counter does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, CounterConfig>> counter(
Expand All @@ -141,7 +138,6 @@ class CounterDefinition
* Checks if a metric with the given name is registered.
*
* @param name Name of the requested query.
*
* @return True, if the metric exists.
*/
[[nodiscard]] bool is_metric(const std::string& name) const noexcept { return _metrics.find(name) != _metrics.end(); }
Expand All @@ -150,7 +146,6 @@ class CounterDefinition
* Checks if a metric with the given name is registered.
*
* @param name Name of the requested metric.
*
* @return True, if the metric exists.
*/
[[nodiscard]] bool is_metric(std::string_view name) const noexcept
Expand All @@ -162,7 +157,6 @@ class CounterDefinition
* Checks if a specific metric is registered and returns the name and the metric.
*
* @param name Name of the queried metric.
*
* @return Metric and config, std::nullopt of the metric does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, Metric&>> metric(const std::string& name) const noexcept;
Expand All @@ -171,7 +165,6 @@ class CounterDefinition
* Checks if a specific metric is registered and returns the name and the metric.
*
* @param name Name of the queried metric.
*
* @return Metric and config, std::nullopt of the metric does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, Metric&>> metric(std::string&& name) const noexcept
Expand All @@ -183,7 +176,6 @@ class CounterDefinition
* Checks if a specific metric is registered and returns the name and the metric.
*
* @param name Name of the queried metric.
*
* @return Metric and config, std::nullopt of the metric does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, Metric&>> metric(const std::string_view name) const noexcept
Expand All @@ -195,7 +187,6 @@ class CounterDefinition
* Checks if a time event with the given name is registered.
*
* @param name Name of the requested time event.
*
* @return True, if the time event exists.
*/
[[nodiscard]] bool is_time_event(const std::string& name) const noexcept
Expand All @@ -207,7 +198,6 @@ class CounterDefinition
* Checks if a time event with the given name is registered.
*
* @param name Name of the requested time event.
*
* @return True, if the time event exists.
*/
[[nodiscard]] bool is_time_event(std::string&& name) const noexcept { return is_time_event(name); }
Expand All @@ -216,7 +206,6 @@ class CounterDefinition
* Checks if a time event with the given name is registered.
*
* @param name Name of the requested time event.
*
* @return True, if the time event exists.
*/
[[nodiscard]] bool is_time_event(const std::string_view name) const noexcept
Expand All @@ -228,7 +217,6 @@ class CounterDefinition
* Checks if a specific time event is registered and returns the name and the time event.
*
* @param name Name of the queried time event.
*
* @return Time event and config, std::nullopt of the time event does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, TimeEvent&>> time_event(
Expand All @@ -238,7 +226,6 @@ class CounterDefinition
* Checks if a specific time event is registered and returns the name and the time event.
*
* @param name Name of the queried time event.
*
* @return Time event and config, std::nullopt of the time event does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, TimeEvent&>> time_event(std::string&& name) const noexcept
Expand All @@ -250,7 +237,6 @@ class CounterDefinition
* Checks if a specific time event is registered and returns the name and the time event.
*
* @param name Name of the queried time event.
*
* @return Time event and config, std::nullopt of the time event does not exist.
*/
[[nodiscard]] std::optional<std::pair<std::string_view, TimeEvent&>> time_event(
Expand All @@ -265,9 +251,10 @@ class CounterDefinition
[[nodiscard]] std::vector<std::string> names() const
{
auto names = std::vector<std::string>{};
std::transform(_counter_configs.begin(), _counter_configs.end(), std::back_inserter(names), [](const auto& config) {
return config.first;
});
std::transform(_hardware_counter_configurations.begin(),
_hardware_counter_configurations.end(),
std::back_inserter(names),
[](const auto& config) { return config.first; });
return names;
}

Expand All @@ -279,7 +266,7 @@ class CounterDefinition

private:
/// List of added counter configurations.
std::unordered_map<std::string, CounterConfig> _counter_configs;
std::unordered_map<std::string, CounterConfig> _hardware_counter_configurations;

/// List of added metrics.
std::unordered_map<std::string, std::unique_ptr<Metric>> _metrics;
Expand Down
1 change: 0 additions & 1 deletion include/perfcpp/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class Group
* @param max_callstack_size Maximal size of sampled callstacks, std::nullopt of sampling is disabled.
* @param is_include_context_switch True, if context switches should be sampled, ignored if sampling is disabled.
* @param is_include_cgroup True, if cgroups should be sampled, ignored if sampling is disabled.
*
* @return True, if the counters could be opened.
*/
bool open(const Config& config,
Expand Down
4 changes: 0 additions & 4 deletions include/perfcpp/requested_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class RequestedEventSet
*
* @param event_name Name of the event.
* @param in_group_position Position of the event within the group.
*
* @return True, if the event was added. False, if the event was already in the event set.
*/
bool add(const std::string_view event_name, const std::uint8_t in_group_position)
Expand All @@ -129,7 +128,6 @@ class RequestedEventSet
* @param is_shown_in_results True, if the event should be visible in the results.
* @param group_id Id of the group the event was scheduled to.
* @param in_group_position Position of the event within the group.
*
* @return True, if the event was added. False, if the event was already in the event set.
*/
bool add(const std::string_view event_name,
Expand All @@ -150,7 +148,6 @@ class RequestedEventSet
* @param event_name Name of the event.
* @param type Type of the event (e.g., metric or time)
* @param is_shown_in_results True, if the event should be visible in the results.
*
* @return True, if the event was added. False, if the event was already in the event set.
*/
bool add(const std::string_view event_name, const RequestedEvent::Type type, const bool is_shown_in_results)
Expand Down Expand Up @@ -212,7 +209,6 @@ class RequestedEventSet
* @param type Type, e.g., hardware event, metric, or time event.
* @param scheduled_group Group id and position within the group the hardware event is scheduled to (if the event is a
* hardware event).
*
* @return True, if the event was added. False, if the event was already in the event set.
*/
bool add(std::string_view event_name,
Expand Down
Loading

0 comments on commit 2f19f0b

Please sign in to comment.