mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 20:40:18 +00:00
* init * some optimize * Update frame.h * remove `LOAD_INTEGER` * Update vm.cpp * some optimize * some fix * Revert "remove `LOAD_INTEGER`" This reverts commit c0b965aee2f64fbfae0b20f41d714688649d20cf. * some fix * Update expr.cpp * some fix * Update retype.yml
36 lines
657 B
C++
36 lines
657 B
C++
#pragma once
|
|
|
|
#include "frame.h"
|
|
|
|
namespace pkpy {
|
|
|
|
struct _LineRecord{
|
|
int line;
|
|
i64 hits;
|
|
clock_t time;
|
|
|
|
_LineRecord(): line(-1), hits(0), time(0) {}
|
|
bool is_valid() const { return line != -1; }
|
|
};
|
|
|
|
struct _FrameRecord{
|
|
LinkedFrame* frame;
|
|
clock_t prev_time;
|
|
_LineRecord* prev_record;
|
|
};
|
|
|
|
struct LineProfiler{
|
|
// filename -> records
|
|
std::map<std::string_view, std::vector<_LineRecord>> records;
|
|
stack_no_copy<_FrameRecord> frames;
|
|
std::set<FuncDecl*> functions;
|
|
|
|
void begin();
|
|
void _step(LinkedFrame*);
|
|
void _step_end(LinkedFrame*, int);
|
|
void end();
|
|
Str stats();
|
|
};
|
|
|
|
} // namespace pkpy
|