mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-27 15:00:18 +00:00
Compare commits
No commits in common. "352556cbeaf2a3d88026d86ac820b9cec80a1e32" and "b786fda39d0706d03dc70835d9384233f6dbb8d5" have entirely different histories.
352556cbea
...
b786fda39d
@ -14,7 +14,6 @@ typedef struct FrameRecord {
|
|||||||
py_Frame* frame;
|
py_Frame* frame;
|
||||||
clock_t prev_time;
|
clock_t prev_time;
|
||||||
LineRecord* prev_line;
|
LineRecord* prev_line;
|
||||||
bool is_lambda;
|
|
||||||
} FrameRecord;
|
} FrameRecord;
|
||||||
|
|
||||||
typedef struct LineProfiler {
|
typedef struct LineProfiler {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
name: pocketpy
|
name: pocketpy
|
||||||
description: A lightweight Python interpreter for game engines. It supports Android/iOS/Windows/Linux/MacOS.
|
description: A lightweight Python interpreter for game engines. It supports Android/iOS/Windows/Linux/MacOS.
|
||||||
version: 2.1.1
|
version: 2.0.8
|
||||||
homepage: https://pocketpy.dev
|
homepage: https://pocketpy.dev
|
||||||
repository: https://github.com/pocketpy/pocketpy
|
repository: https://github.com/pocketpy/pocketpy
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#include "pocketpy/common/sstream.h"
|
#include "pocketpy/common/sstream.h"
|
||||||
#include "pocketpy/interpreter/line_profiler.h"
|
#include "pocketpy/interpreter/line_profiler.h"
|
||||||
#include "pocketpy/interpreter/frame.h"
|
#include "pocketpy/interpreter/frame.h"
|
||||||
#include "pocketpy/objects/codeobject.h"
|
|
||||||
#include "pocketpy/objects/sourcedata.h"
|
#include "pocketpy/objects/sourcedata.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -42,14 +41,14 @@ void LineProfiler__begin(LineProfiler* self) {
|
|||||||
|
|
||||||
static void LineProfiler__increment_now(LineProfiler* self, clock_t now, LineRecord* curr_line) {
|
static void LineProfiler__increment_now(LineProfiler* self, clock_t now, LineRecord* curr_line) {
|
||||||
FrameRecord* top_frame_record = &c11_vector__back(FrameRecord, &self->frame_records);
|
FrameRecord* top_frame_record = &c11_vector__back(FrameRecord, &self->frame_records);
|
||||||
if(!top_frame_record->is_lambda) {
|
LineRecord* prev_line = top_frame_record->prev_line;
|
||||||
LineRecord* prev_line = top_frame_record->prev_line;
|
clock_t delta = now - top_frame_record->prev_time;
|
||||||
clock_t delta = now - top_frame_record->prev_time;
|
top_frame_record->prev_time = now;
|
||||||
top_frame_record->prev_time = now;
|
prev_line->hits++;
|
||||||
prev_line->hits++;
|
prev_line->time += delta;
|
||||||
prev_line->time += delta;
|
|
||||||
// printf(" ==> increment_now: delta: %ld, hits: %lld\n", delta, prev_line->hits);
|
// printf(" ==> increment_now: delta: %ld, hits: %lld\n",
|
||||||
}
|
// delta, prev_line->hits);
|
||||||
top_frame_record->prev_line = curr_line;
|
top_frame_record->prev_line = curr_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,15 +68,7 @@ void LineProfiler__tracefunc_internal(LineProfiler* self,
|
|||||||
LineProfiler__increment_now(self, now, curr_line);
|
LineProfiler__increment_now(self, now, curr_line);
|
||||||
} else {
|
} else {
|
||||||
if(event == TRACE_EVENT_PUSH) {
|
if(event == TRACE_EVENT_PUSH) {
|
||||||
FrameRecord f_record = {.frame = frame,
|
FrameRecord f_record = {.frame = frame, .prev_time = now, .prev_line = curr_line};
|
||||||
.prev_time = now,
|
|
||||||
.prev_line = curr_line,
|
|
||||||
.is_lambda = false};
|
|
||||||
if(!frame->is_locals_special && py_istype(frame->p0, tp_function)) {
|
|
||||||
Function* fn = py_touserdata(frame->p0);
|
|
||||||
c11_string* fn_name = fn->decl->code.name;
|
|
||||||
f_record.is_lambda = fn_name->size > 0 && fn_name->data[0] == '<';
|
|
||||||
}
|
|
||||||
c11_vector__push(FrameRecord, &self->frame_records, f_record);
|
c11_vector__push(FrameRecord, &self->frame_records, f_record);
|
||||||
} else if(event == TRACE_EVENT_POP) {
|
} else if(event == TRACE_EVENT_POP) {
|
||||||
LineProfiler__increment_now(self, now, NULL);
|
LineProfiler__increment_now(self, now, NULL);
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void py_setslot(py_Ref self, int i, py_Ref val) {
|
|||||||
|
|
||||||
py_StackRef py_inspect_currentfunction() {
|
py_StackRef py_inspect_currentfunction() {
|
||||||
VM* vm = pk_current_vm;
|
VM* vm = pk_current_vm;
|
||||||
if(vm->curr_decl_based_function) return vm->curr_decl_based_function;
|
if(vm->curr_decl_based_function) { return vm->curr_decl_based_function; }
|
||||||
py_Frame* frame = vm->top_frame;
|
py_Frame* frame = vm->top_frame;
|
||||||
if(!frame || frame->is_locals_special) return NULL;
|
if(!frame || frame->is_locals_special) return NULL;
|
||||||
return frame->p0;
|
return frame->p0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user