2014-01-03 08:20:13 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Позволяет считать количество различных событий, произошедших в программе
|
|
|
|
|
* - для высокоуровневого профайлинга.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define APPLY_FOR_EVENTS(M) \
|
|
|
|
|
M(Query, "Queries") \
|
|
|
|
|
M(SelectQuery, "Select queries") \
|
|
|
|
|
M(InsertQuery, "Insert queries") \
|
|
|
|
|
M(FileOpen, "File opens") \
|
|
|
|
|
M(Seek, "Seeks") \
|
|
|
|
|
M(ReadBufferFromFileDescriptorRead, "ReadBufferFromFileDescriptor reads") \
|
|
|
|
|
M(ReadCompressedBytes, "Read compressed bytes") \
|
|
|
|
|
M(CompressedReadBufferBlocks, "Read decompressed blocks") \
|
|
|
|
|
M(CompressedReadBufferBytes, "Read decompressed bytes") \
|
|
|
|
|
M(UncompressedCacheHits, "Uncompressed cache hits") \
|
|
|
|
|
M(UncompressedCacheMisses, "Uncompressed cache misses") \
|
2014-04-17 15:46:58 +00:00
|
|
|
|
M(UncompressedCacheWeightLost, "Uncompressed cache weight lost") \
|
2014-01-04 04:53:07 +00:00
|
|
|
|
M(IOBufferAllocs, "IO buffers allocations") \
|
|
|
|
|
M(IOBufferAllocBytes, "IO buffers allocated bytes") \
|
|
|
|
|
M(ArenaAllocChunks, "Arena allocated chunks") \
|
|
|
|
|
M(ArenaAllocBytes, "Arena allocated bytes") \
|
|
|
|
|
M(FunctionExecute, "Function executes") \
|
2014-02-11 13:30:42 +00:00
|
|
|
|
M(MarkCacheHits, "Mark cache hits") \
|
|
|
|
|
M(MarkCacheMisses, "Mark cache misses") \
|
2014-04-08 17:45:21 +00:00
|
|
|
|
\
|
2014-04-07 15:45:46 +00:00
|
|
|
|
M(ReplicatedPartFetches, "Replicated part fetches") \
|
2014-04-08 17:45:21 +00:00
|
|
|
|
M(ReplicatedPartFailedFetches, "Replicated part fetches failed") \
|
2014-04-07 15:45:46 +00:00
|
|
|
|
M(ObsoleteReplicatedParts, "Replicated parts rendered obsolete by fetches") \
|
|
|
|
|
M(ReplicatedPartMerges, "Replicated part merges") \
|
|
|
|
|
M(ReplicatedPartFetchesOfMerged, "Replicated part merges replaced with fetches") \
|
2014-01-03 08:20:13 +00:00
|
|
|
|
\
|
|
|
|
|
M(END, "")
|
|
|
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
|
{
|
|
|
|
|
/// Виды событий.
|
|
|
|
|
enum Event
|
|
|
|
|
{
|
|
|
|
|
#define M(NAME, DESCRIPTION) NAME,
|
|
|
|
|
APPLY_FOR_EVENTS(M)
|
|
|
|
|
#undef M
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Получить текстовое описание события по его enum-у.
|
|
|
|
|
inline const char * getDescription(Event event)
|
|
|
|
|
{
|
|
|
|
|
static const char * descriptions[] =
|
|
|
|
|
{
|
|
|
|
|
#define M(NAME, DESCRIPTION) DESCRIPTION,
|
|
|
|
|
APPLY_FOR_EVENTS(M)
|
|
|
|
|
#undef M
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return descriptions[event];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Счётчики - сколько раз каждое из событий произошло.
|
2014-01-04 11:43:16 +00:00
|
|
|
|
extern size_t counters[END];
|
2014-01-03 08:20:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Увеличить счётчик события. Потокобезопасно.
|
|
|
|
|
inline void increment(Event event, size_t amount = 1)
|
|
|
|
|
{
|
|
|
|
|
__sync_fetch_and_add(&counters[event], amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef APPLY_FOR_EVENTS
|