No description
  • C++ 96.2%
  • CMake 3.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-01 21:39:37 +01:00
example cleanup: rename Metadata::insert to emplace 2026-11-01 21:12:16 +01:00
include/libmeta feat: Entry::get<I> 2026-11-01 21:39:37 +01:00
test refactor: split compilation from the rest of the API 2026-11-01 04:07:13 +01:00
.clang-format refactor: split compilation from the rest of the API 2026-11-01 04:07:13 +01: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 cleanup: rename Metadata::insert to emplace 2026-11-01 21:12:16 +01: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::emplace<meta_marker, meta_file,           \
                                             meta_line>();                     \
        }())

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