Skip to content

Commit b293b95

Browse files
committed
remove suffix
Signed-off-by: niranda perera <niranda.perera@gmail.com>
1 parent ea4037d commit b293b95

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

cpp/include/rapidsmpf/statistics.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,16 @@ class Statistics {
522522
*
523523
* @param src Source memory type.
524524
* @param nbytes Number of bytes sent.
525-
* @param suffix Suffix to add to the statistic name.
526525
*/
527-
void record_send(MemoryType src, std::size_t nbytes, std::string_view suffix = "");
526+
void record_send(MemoryType src, std::size_t nbytes);
528527

529528
/**
530529
* @brief Record byte count for a receive operation.
531530
*
532531
* @param dst Destination memory type.
533532
* @param nbytes Number of bytes received.
534-
* @param suffix Suffix to add to the statistic name.
535533
*/
536-
void record_recv(MemoryType dst, std::size_t nbytes, std::string_view suffix = "");
534+
void record_recv(MemoryType dst, std::size_t nbytes);
537535

538536
/**
539537
* @brief Get the names of all statistics.

cpp/src/statistics.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -681,20 +681,26 @@ std::shared_ptr<Statistics> Statistics::merge(
681681
return ret;
682682
}
683683

684-
void Statistics::record_send(
685-
MemoryType src, std::size_t nbytes, std::string_view suffix
686-
) {
687-
add_stat(
688-
std::format("send-from-{}{}", to_string(src), suffix), static_cast<double>(nbytes)
689-
);
684+
void Statistics::record_send(MemoryType src, std::size_t nbytes) {
685+
static auto const names = [] {
686+
std::array<std::string, MEMORY_TYPE_NAMES.size()> ret;
687+
std::ranges::transform(MEMORY_TYPE_NAMES, ret.begin(), [](char const* n) {
688+
return std::format("send-from-{}", n);
689+
});
690+
return ret;
691+
}();
692+
add_stat(names[static_cast<std::size_t>(src)], static_cast<double>(nbytes));
690693
}
691694

692-
void Statistics::record_recv(
693-
MemoryType dst, std::size_t nbytes, std::string_view suffix
694-
) {
695-
add_stat(
696-
std::format("recv-to-{}{}", to_string(dst), suffix), static_cast<double>(nbytes)
697-
);
695+
void Statistics::record_recv(MemoryType dst, std::size_t nbytes) {
696+
static auto const names = [] {
697+
std::array<std::string, MEMORY_TYPE_NAMES.size()> ret;
698+
std::ranges::transform(MEMORY_TYPE_NAMES, ret.begin(), [](char const* n) {
699+
return std::format("recv-to-{}", n);
700+
});
701+
return ret;
702+
}();
703+
add_stat(names[static_cast<std::size_t>(dst)], static_cast<double>(nbytes));
698704
}
699705

700706
void Statistics::record_copy(

0 commit comments

Comments
 (0)