Skip to content

Commit

Permalink
distinguish profiled items of different instantiations of the same te…
Browse files Browse the repository at this point in the history
…mplate
  • Loading branch information
matekelemen committed Dec 15, 2024
1 parent 415df9a commit f04db9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion kratos/sources/profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ void Profiler<T>::Write(std::ostream& rStream) const
const auto& r_location = p_item->mLocation;
result.AddString("file", std::string(r_location.GetFileName()));
result.AddInt("line", int(r_location.GetLineNumber()));
result.AddString("function", std::string(r_location.GetFunctionName()));
result.AddString("signature", std::string(r_location.GetFunctionName()));
result.AddString("function", std::string(r_location.CleanFunctionName()));
result.AddInt("callCount", p_item->mCallCount);

std::stringstream stream;
Expand Down
13 changes: 6 additions & 7 deletions kratos/utilities/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@ class KRATOS_API(KRATOS_CORE) Profiler

struct SourceLocationHash
{
std::size_t operator()(const CodeLocation& r_argument) const
std::size_t operator()(const CodeLocation& rArgument) const
{
std::string string(r_argument.GetFileName());
string.append(std::to_string(r_argument.GetLineNumber()));
return std::hash<std::string>()(string);
return std::hash<std::string>()(rArgument.GetFileName() + rArgument.GetFunctionName());
}
};

struct SourceLocationEquality
{
bool operator()(const CodeLocation& r_lhs,
const CodeLocation& r_rhs) const
bool operator()(const CodeLocation& rLhs,
const CodeLocation& rRhs) const
{
return (std::string(r_lhs.GetFileName()) == std::string(r_rhs.GetFileName())) && (r_lhs.GetLineNumber() == r_rhs.GetLineNumber());
return (rLhs.GetFileName() == rRhs.GetFileName())
&& (rLhs.GetFunctionName() == rRhs.GetFunctionName());
}
};

Expand Down
1 change: 0 additions & 1 deletion kratos/utilities/profiler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "utilities/profiler.h" // <== help the language server

// System includes
#include <string>
#include <chrono>


Expand Down

0 comments on commit f04db9e

Please sign in to comment.