Skip to content

Commit

Permalink
JIT: Add a simple Counter dumpable (#98350)
Browse files Browse the repository at this point in the history
This allows easily measuring and outputting a single value at the end of
all JIT compilations.
  • Loading branch information
jakobbotsch authored Feb 14, 2024
1 parent 28b6eef commit 0ce39a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,19 @@ class Dumpable
virtual void dump(FILE* output) = 0;
};

// Helper class record and display a simple single value.
class Counter : public Dumpable
{
public:
int64_t Value;

Counter(int64_t initialValue = 0) : Value(initialValue)
{
}

void dump(FILE* output);
};

// Helper class to record and display a histogram of different values.
// Usage like:
// static unsigned s_buckets[] = { 1, 2, 5, 10, 0 }; // Must have terminating 0
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,11 @@ void ConfigDoubleArray::Dump()

#if CALL_ARG_STATS || COUNT_BASIC_BLOCKS || COUNT_LOOPS || EMITTER_STATS || MEASURE_NODE_SIZE || MEASURE_MEM_ALLOC

void Counter::dump(FILE* output)
{
fprintf(output, "%lld\n", (long long)Value);
}

/*****************************************************************************
* Histogram class.
*/
Expand Down

0 comments on commit 0ce39a1

Please sign in to comment.