diff --git a/include/perfcpp/analyzer/memory_access.h b/include/perfcpp/analyzer/memory_access.h index 2c87b73..ba3d913 100644 --- a/include/perfcpp/analyzer/memory_access.h +++ b/include/perfcpp/analyzer/memory_access.h @@ -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>>>::iterator find( diff --git a/include/perfcpp/counter_definition.h b/include/perfcpp/counter_definition.h index 0de3fd2..7cfb756 100644 --- a/include/perfcpp/counter_definition.h +++ b/include/perfcpp/counter_definition.h @@ -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)); } /** @@ -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> counter(std::string&& name) const noexcept @@ -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> counter( @@ -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> counter( @@ -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(); } @@ -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 @@ -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> metric(const std::string& name) const noexcept; @@ -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> metric(std::string&& name) const noexcept @@ -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> metric(const std::string_view name) const noexcept @@ -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 @@ -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); } @@ -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 @@ -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> time_event( @@ -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> time_event(std::string&& name) const noexcept @@ -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> time_event( @@ -265,9 +251,10 @@ class CounterDefinition [[nodiscard]] std::vector names() const { auto names = std::vector{}; - 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; } @@ -279,7 +266,7 @@ class CounterDefinition private: /// List of added counter configurations. - std::unordered_map _counter_configs; + std::unordered_map _hardware_counter_configurations; /// List of added metrics. std::unordered_map> _metrics; diff --git a/include/perfcpp/group.h b/include/perfcpp/group.h index 20774a2..73fe154 100644 --- a/include/perfcpp/group.h +++ b/include/perfcpp/group.h @@ -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, diff --git a/include/perfcpp/requested_event.h b/include/perfcpp/requested_event.h index f01ae8d..b98c5d5 100644 --- a/include/perfcpp/requested_event.h +++ b/include/perfcpp/requested_event.h @@ -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) @@ -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, @@ -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) @@ -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, diff --git a/include/perfcpp/sample.h b/include/perfcpp/sample.h index ccef1ff..09616fd 100644 --- a/include/perfcpp/sample.h +++ b/include/perfcpp/sample.h @@ -174,54 +174,63 @@ class Sample /* * Returns the mode in which the sample was taken (e.g., Kernel, User, Hypervisor). + * * @return The sample mode. */ [[nodiscard]] Mode mode() const noexcept { return _mode; } /* * Retrieves the unique identifier for the sample. + * * @return An optional containing the sample ID if available. */ [[nodiscard]] std::optional sample_id() const noexcept { return _sample_id; } /* * Retrieves the instruction pointer at the time the sample was recorded. + * * @return An optional containing the instruction pointer address if available. */ [[nodiscard]] std::optional instruction_pointer() const noexcept { return _instruction_pointer; } /* * Retrieves the process ID associated with the sample. + * * @return An optional containing the process ID if available. */ [[nodiscard]] std::optional process_id() const noexcept { return _process_id; } /* * Retrieves the thread ID associated with the sample. + * * @return An optional containing the thread ID if available. */ [[nodiscard]] std::optional thread_id() const noexcept { return _thread_id; } /* * Retrieves the timestamp when the sample was taken. + * * @return An optional containing the timestamp if available. */ [[nodiscard]] std::optional time() const noexcept { return _time; } /* * Retrieves the stream id. + * * @return An optional containing the stream id if available. */ [[nodiscard]] std::optional stream_id() const noexcept { return _stream_id; } /* * Retrieves raw data. + * * @return An optional containing raw data if available. */ [[nodiscard]] const std::optional>& raw() const noexcept { return _raw_data; } /* * Retrieves the logical (virtual) memory address relevant to the sample. + * * @return An optional containing the logical memory address if available. */ [[nodiscard]] std::optional logical_memory_address() const noexcept @@ -231,6 +240,7 @@ class Sample /* * Retrieves the physical memory address relevant to the sample. + * * @return An optional containing the physical memory address if available. */ [[nodiscard]] std::optional physical_memory_address() const noexcept @@ -240,72 +250,84 @@ class Sample /* * Retrieves the unique ID of the perf_event that generated the sample. + * * @return An optional containing the perf_event ID if available. */ [[nodiscard]] std::optional id() const noexcept { return _id; } /* * Retrieves the CPU ID where the sample was collected. + * * @return An optional containing the CPU ID if available. */ [[nodiscard]] std::optional cpu_id() const noexcept { return _cpu_id; } /* * Retrieves the period value indicating the number of events that have occurred. + * * @return An optional containing the period value if available. */ [[nodiscard]] std::optional period() const noexcept { return _period; } /* * Retrieves the counter result associated with the sample. + * * @return An optional containing the counter result if available. */ [[nodiscard]] const std::optional& counter_result() const noexcept { return _counter_result; } /* * Retrieves the counter result associated with the sample. + * * @return An optional containing the counter result if available. */ [[nodiscard]] const std::optional& counter() const noexcept { return _counter_result; } /* * Retrieves the data source information of the sample. + * * @return An optional containing the data source if available. */ [[nodiscard]] std::optional data_src() const noexcept { return _data_src; } /* * Retrieves the transaction abort of the sample. + * * @return An optional containing the transaction abort if available. */ [[nodiscard]] std::optional transaction_abort() const noexcept { return _transaction_abort; } /* * Retrieves the weight value representing the cost or impact of the sample. + * * @return An optional containing the weight if available. */ [[nodiscard]] std::optional weight() const noexcept { return _weight; } /* * Retrieves the branches recorded in the sample. + * * @return An optional vector of branches if available. */ [[nodiscard]] const std::optional>& branches() const noexcept { return _branches; } /* * Retrieves the branches recorded in the sample (modifiable). + * * @return An optional vector of branches if available. */ [[nodiscard]] std::optional>& branches() noexcept { return _branches; } /* * Retrieves the ABI of the user-space registers. + * * @return An optional containing the user registers ABI if available. */ [[nodiscard]] std::optional user_registers_abi() const noexcept { return _user_registers_abi; } /* * Retrieves the user-space registers captured in the sample. + * * @return An optional vector of user registers if available. */ [[nodiscard]] const std::optional>& user_registers() const noexcept @@ -315,18 +337,21 @@ class Sample /* * Retrieves the user-space registers captured in the sample (modifiable). + * * @return An optional vector of user registers if available. */ [[nodiscard]] std::optional>& user_registers() noexcept { return _user_registers; } /* * Retrieves the ABI of the kernel-space registers. + * * @return An optional containing the kernel registers ABI if available. */ [[nodiscard]] std::optional kernel_registers_abi() const noexcept { return _kernel_registers_abi; } /* * Retrieves the kernel-space registers captured in the sample. + * * @return An optional vector of kernel registers if available. */ [[nodiscard]] const std::optional>& kernel_registers() const noexcept @@ -336,78 +361,91 @@ class Sample /* * Retrieves the kernel-space registers captured in the sample (modifiable). + * * @return An optional vector of kernel registers if available. */ [[nodiscard]] std::optional>& kernel_registers() noexcept { return _kernel_registers; } /* * Retrieves the user stack captured in the sample (modifiable). + * * @return An optional vector of user stack data if available. */ [[nodiscard]] const std::optional>& user_stack() const noexcept { return _user_stack; } /* * Retrieves the user stack captured in the sample (modifiable). + * * @return An optional vector of user stack data if available. */ [[nodiscard]] std::optional>& user_stack() noexcept { return _user_stack; } /* * Retrieves the call chain (stack backtrace) captured in the sample. + * * @return An optional vector of instruction pointers if available. */ [[nodiscard]] const std::optional>& callchain() const noexcept { return _callchain; } /* * Retrieves the call chain (stack backtrace) captured in the sample (modifiable). + * * @return An optional vector of instruction pointers if available. */ [[nodiscard]] std::optional>& callchain() noexcept { return _callchain; } /* * Retrieves the cgroup ID of the for the perf_event subsystem. + * * @return An optional containing the cgroup ID if available. */ [[nodiscard]] std::optional cgroup_id() const noexcept { return _cgroup_id; } /* * Retrieves the cgroup. CGroups are recorded when created and activated. + * * @return An optional containing the cgroup if available. */ [[nodiscard]] const std::optional& cgroup() const noexcept { return _cgroup; } /* * Retrieves the data page size at the time of the sample. + * * @return An optional containing the data page size if available. */ [[nodiscard]] std::optional data_page_size() const noexcept { return _data_page_size; } /* * Retrieves the code page size at the time of the sample. + * * @return An optional containing the code page size if available. */ [[nodiscard]] std::optional code_page_size() const noexcept { return _code_page_size; } /* * Retrieves the context switch. + * * @return An optional containing the context switch if available. */ [[nodiscard]] std::optional context_switch() const noexcept { return _context_switch; } /* * Retrieves the count of lost events associated with the sample. + * * @return An optional containing the count of lost events if available. */ [[nodiscard]] std::optional count_loss() const noexcept { return _count_loss; } /* * Retrieves a throttle/unthrottle event. + * * @return An optional containing a throttle or an unthrottle flag if available. */ [[nodiscard]] std::optional throttle() const noexcept { return _throttle; } /* * Indicates whether the instruction pointer in the sample is exact. + * * @return True if the instruction pointer is exact; otherwise, false. */ [[nodiscard]] bool is_exact_ip() const noexcept { return _is_exact_ip; } diff --git a/include/perfcpp/sampler.h b/include/perfcpp/sampler.h index 4ea037f..96ebe3f 100644 --- a/include/perfcpp/sampler.h +++ b/include/perfcpp/sampler.h @@ -628,7 +628,6 @@ class Sampler * * @param entry Entry of the user-level buffer. * @param sample_counter The SampleCounter the entry is linked to in order to get the recorded counters (if any). - * * @return Sample. */ [[nodiscard]] perf::Sample read_sample_event(UserLevelBufferEntry entry, const SampleCounter& sample_counter) const; @@ -638,7 +637,6 @@ class Sampler * * @param entry Current position at the buffer. * @param count_registers Number of registers requested. - * * @return Pair of ABI and list of registers (if any). */ [[nodiscard]] static std::pair>> read_registers( @@ -650,7 +648,6 @@ class Sampler * * @param entry Current position at the buffer. * @param sample_counter The current sample counter including the counter group and counter names. - * * @return Event values */ [[nodiscard]] std::optional read_hardware_events(UserLevelBufferEntry& entry, @@ -660,7 +657,6 @@ class Sampler * Reads the callchain from the current buffer entry. * * @param entry Current position at the buffer. - * * @return List of instruction pointers (the callchain). */ [[nodiscard]] static std::optional> read_callchain(UserLevelBufferEntry& entry); @@ -669,7 +665,6 @@ class Sampler * Reads the branch stack from the current buffer entry. * * @param entry Current position at the buffer. - * * @return Branch stack. */ [[nodiscard]] static std::optional> read_branch_stack(UserLevelBufferEntry& entry); @@ -678,7 +673,6 @@ class Sampler * Translates the current entry from the user-level buffer into a lost sample. * * @param entry Entry of the user-level buffer. - * * @return Sample containing the loss. */ [[nodiscard]] perf::Sample read_loss_event(UserLevelBufferEntry entry) const noexcept; @@ -687,7 +681,6 @@ class Sampler * Translates the current entry from the user-level buffer into a context switch sample. * * @param entry Entry of the user-level buffer. - * * @return Sample containing the context switch. */ [[nodiscard]] perf::Sample read_context_switch_event(UserLevelBufferEntry entry) const noexcept; @@ -696,7 +689,6 @@ class Sampler * Translates the current entry from the user-level buffer into a cgroup sample. * * @param entry Entry of the user-level buffer. - * * @return Sample containing the cgroup. */ [[nodiscard]] static perf::Sample read_cgroup_event(UserLevelBufferEntry entry); @@ -705,7 +697,6 @@ class Sampler * Translates the current entry from the user-level buffer into a throttle or un-throttle sample. * * @param entry Entry of the user-level buffer. - * * @return Sample containing the throttle. */ [[nodiscard]] perf::Sample read_throttle_event(UserLevelBufferEntry entry) const noexcept; @@ -870,7 +861,6 @@ class MultiThreadSampler final : public MultiSamplerBase * Set the trigger for sampling to a single counter. * * @param trigger_name Name of the counter that "triggers" sample recording. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::string&& trigger_name) @@ -884,7 +874,6 @@ class MultiThreadSampler final : public MultiSamplerBase * * @param trigger_name Name of the counter that "triggers" sample recording. * @param precision Precision of the event. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::string&& trigger_name, const Precision precision) @@ -898,7 +887,6 @@ class MultiThreadSampler final : public MultiSamplerBase * * @param trigger_name Name of the counter that "triggers" sample recording. * @param period Sampling period of the event. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::string&& trigger_name, const class Period period) @@ -912,7 +900,6 @@ class MultiThreadSampler final : public MultiSamplerBase * * @param trigger_name Name of the counter that "triggers" sample recording. * @param frequency Sampling frequency of the event. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::string&& trigger_name, const Frequency frequency) @@ -927,7 +914,6 @@ class MultiThreadSampler final : public MultiSamplerBase * @param trigger_name Name of the counter that "triggers" sample recording. * @param precision Precision of the event. * @param period Sampling period of the event. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::string&& trigger_name, const Precision precision, const class Period period) @@ -940,7 +926,6 @@ class MultiThreadSampler final : public MultiSamplerBase * Set the trigger for sampling to a list of different counters (e.g., mem loads and mem stores). * * @param trigger_name Name of the counters that "triggers" sample recording. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::vector&& trigger_names) @@ -952,7 +937,6 @@ class MultiThreadSampler final : public MultiSamplerBase * Set the trigger for sampling to a list of different counters (e.g., mem loads and mem stores). * * @param triggers List of triggers tuples that "trigger" sample recording. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::vector&& triggers) @@ -966,7 +950,6 @@ class MultiThreadSampler final : public MultiSamplerBase * for Intel's Sapphire Rapids architecture). * * @param trigger_name Group of names of the counters that "triggers" sample recording. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::vector>&& trigger_names) @@ -981,7 +964,6 @@ class MultiThreadSampler final : public MultiSamplerBase * for Intel's Sapphire Rapids architecture). * * @param triggers Group of names and precisions of the counters that "trigger" sample recording. - * * @return MultiThreadSampler */ MultiThreadSampler& trigger(std::vector>&& triggers) @@ -1001,7 +983,6 @@ class MultiThreadSampler final : public MultiSamplerBase * Opens and starts recording performance counters on a specific thread. * * @param thread_id Id of the thread to start. - * * @return True, of the performance counters could be started. */ bool start(const std::uint16_t thread_id) @@ -1056,7 +1037,6 @@ class MultiCoreSampler final : public MultiSamplerBase * Set the trigger for sampling to a single counter. * * @param trigger_name Name of the counter that "triggers" sample recording. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::string&& trigger_name) @@ -1070,7 +1050,6 @@ class MultiCoreSampler final : public MultiSamplerBase * * @param trigger_name Name of the counter that "triggers" sample recording. * @param precision Precision of the event. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::string&& trigger_name, const Precision precision) @@ -1084,7 +1063,6 @@ class MultiCoreSampler final : public MultiSamplerBase * * @param trigger_name Name of the counter that "triggers" sample recording. * @param period Sampling period of the event. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::string&& trigger_name, const class Period period) @@ -1098,7 +1076,6 @@ class MultiCoreSampler final : public MultiSamplerBase * * @param trigger_name Name of the counter that "triggers" sample recording. * @param frequency Sampling frequency of the event. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::string&& trigger_name, const Frequency frequency) @@ -1113,7 +1090,6 @@ class MultiCoreSampler final : public MultiSamplerBase * @param trigger_name Name of the counter that "triggers" sample recording. * @param precision Precision of the event. * @param period Sampling period of the event. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::string&& trigger_name, const Precision precision, const class Period period) @@ -1126,7 +1102,6 @@ class MultiCoreSampler final : public MultiSamplerBase * Set the trigger for sampling to a list of different counters (e.g., mem loads and mem stores). * * @param trigger_name Name of the counters that "triggers" sample recording. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::vector&& trigger_names) @@ -1138,7 +1113,6 @@ class MultiCoreSampler final : public MultiSamplerBase * Set the trigger for sampling to a list of different counters (e.g., mem loads and mem stores). * * @param triggers List of triggers tuples that "trigger" sample recording. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::vector&& triggers) @@ -1152,7 +1126,6 @@ class MultiCoreSampler final : public MultiSamplerBase * for Intel's Sapphire Rapids architecture). * * @param trigger_name Group of names of the counters that "triggers" sample recording. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::vector>&& trigger_names) @@ -1167,7 +1140,6 @@ class MultiCoreSampler final : public MultiSamplerBase * for Intel's Sapphire Rapids architecture). * * @param triggers Group of names and precisions of the counters that "trigger" sample recording. - * * @return MultiCoreSampler */ MultiCoreSampler& trigger(std::vector>&& triggers) diff --git a/src/counter_definition.cpp b/src/counter_definition.cpp index 7f3f863..93383e9 100644 --- a/src/counter_definition.cpp +++ b/src/counter_definition.cpp @@ -25,7 +25,8 @@ perf::CounterDefinition::CounterDefinition(const std::string& config_file) std::optional> perf::CounterDefinition::counter(const std::string& name) const noexcept { - if (auto iterator = this->_counter_configs.find(name); iterator != this->_counter_configs.end()) { + if (auto iterator = this->_hardware_counter_configurations.find(name); + iterator != this->_hardware_counter_configurations.end()) { return std::make_optional(std::make_pair(std::string_view(iterator->first), iterator->second)); } @@ -55,7 +56,7 @@ perf::CounterDefinition::time_event(const std::string& name) const noexcept void perf::CounterDefinition::initialize_generalized_counters() { - this->_counter_configs.reserve(128U); + this->_hardware_counter_configurations.reserve(128U); this->_metrics.reserve(64U); this->add("instructions", PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS);