No description
  • C++ 95.9%
  • CMake 4.1%
Find a file
2026-07-27 01:35:31 +02:00
example Initial 2026-07-27 01:35:31 +02:00
include/libmeta Initial 2026-07-27 01:35:31 +02:00
test Initial 2026-07-27 01:35:31 +02:00
.clang-format Initial 2026-07-27 01:35:31 +02:00
.gitignore Initial 2026-07-27 01:35:31 +02:00
CMakeLists.txt Initial 2026-07-27 01:35:31 +02:00
compile_flags.txt Initial 2026-07-27 01:35:31 +02:00
LICENSE Initial 2026-07-27 01:35:31 +02:00
README.md Initial 2026-07-27 01:35:31 +02:00

libmeta

#include <cstdint>
#include <libmeta/metadata.hpp>

static constexpr libmeta::sstring::container section(".meta.profiler");
using ProfilerMetadata = libmeta::Metadata<section,
                                           libmeta::String,            // Marker
                                           libmeta::String,            // File
                                           libmeta::Integral<uint64_t> // Line
                                           >;

uintptr_t profiler_timestamp(uintptr_t token)
{
    // 1. Read WALL TIME
    // 2. Store { token, timestamp } entry to buffer
    // 3. Host reads entry from buffer
    // 4. Host decodes Metadata based on the token and elf file
    // 5. Host correlates Metadata with timestamp
    // 6. Host prints MARKER ( FILE:LINE ) hit at TIMESTAMP
    return token;
}

#define PROFILER_TIMESTAMP(marker)                                             \
    profiler_timestamp(                                                        \
        []()                                                                   \
        {                                                                      \
            static constexpr libmeta::sstring::container meta_marker(marker);  \
            static constexpr libmeta::sstring::container meta_file(__FILE__);  \
            static constexpr uint64_t meta_line = __LINE__;                    \
            return ProfilerMetadata::insert<meta_marker, meta_file,            \
                                            meta_line>();                      \
        }())

int main()
{
    volatile uintptr_t val;
    val = PROFILER_TIMESTAMP("MAIN");
    return 0;
}