Skip to content

Commit

Permalink
kram-profile - add in CBA support
Browse files Browse the repository at this point in the history
The profiler just collects loaded files (as NSData) and then sends them to CBA to generate the report.  Note the code runs json parsing on all the files, and demangle OptFunction again, and then prints the results to the console via fprintf.   Will tie to some UI or report.
  • Loading branch information
alecazam committed Mar 24, 2024
1 parent 8f893c0 commit be60a10
Show file tree
Hide file tree
Showing 15 changed files with 49,309 additions and 0 deletions.
618 changes: 618 additions & 0 deletions kram-profile/CBA/Analysis.cpp

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions kram-profile/CBA/Analysis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Clang Build Analyzer https://github.com/aras-p/ClangBuildAnalyzer
// SPDX-License-Identifier: Unlicense
#pragma once

#include "BuildEvents.h"
#include <stdio.h>

void DoAnalysis(const BuildEvents& events, BuildNames& names, FILE* out);
49 changes: 49 additions & 0 deletions kram-profile/CBA/Arena.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Clang Build Analyzer https://github.com/aras-p/ClangBuildAnalyzer
// SPDX-License-Identifier: Unlicense

#include <cstdint>
#include <algorithm>
#include <vector>

struct ArenaBlock
{
uint8_t* buffer;
size_t bufferSize;
size_t used;
};

static std::vector<ArenaBlock> s_Blocks;

const size_t kDefaultBlockSize = 65536;


void ArenaInitialize()
{
}

void ArenaDelete()
{
for (auto& b : s_Blocks)
delete[] b.buffer;
s_Blocks.clear();
}

void* ArenaAllocate(size_t size)
{
// do we need a new block?
if (s_Blocks.empty() || s_Blocks.back().used + size > s_Blocks.back().bufferSize)
{
ArenaBlock block;
block.bufferSize = std::max(size, kDefaultBlockSize);
block.buffer = new uint8_t[block.bufferSize];
block.used = 0;
s_Blocks.emplace_back(block);
}

// allocate from the last block
ArenaBlock& b = s_Blocks.back();
void* ptr = b.buffer + b.used;
b.used += size;
return ptr;
}

7 changes: 7 additions & 0 deletions kram-profile/CBA/Arena.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Clang Build Analyzer https://github.com/aras-p/ClangBuildAnalyzer
// SPDX-License-Identifier: Unlicense
#pragma once

void ArenaInitialize();
void ArenaDelete();
void* ArenaAllocate(size_t size);
Loading

0 comments on commit be60a10

Please sign in to comment.