From 2ecb697a3fbe556b23bb542ae8444968ed719fcf Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sat, 8 Jul 2023 11:25:25 +0200 Subject: [PATCH] Berry added `getgbl` performance counter to `debug.counters()` (#19070) * Berry add `getgbl` counter * Berry added `getgbl` performance counter to `debug.counters()` --- CHANGELOG.md | 1 + lib/libesp32/berry/src/be_debuglib.c | 1 + lib/libesp32/berry/src/be_vm.c | 4 ++++ lib/libesp32/berry/src/be_vm.h | 1 + 4 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e95efbf29..96b2bc5d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - Command ``BrRestart`` to restart the Berry VM (experimental) (#19003) - Command ``Restart 9`` to save all changes and go into deepsleep waiting for a reset (#19024) - Partition Wizard is now able to convert to safeboot from Shelly partition layout (#19034) +- Berry added `getgbl` performance counter to `debug.counters()` ### Breaking Changed - Berry `bool( [] )` and `bool( {} )` now evaluate as `false` (#18986) diff --git a/lib/libesp32/berry/src/be_debuglib.c b/lib/libesp32/berry/src/be_debuglib.c index 153af55fb..49ee027b0 100644 --- a/lib/libesp32/berry/src/be_debuglib.c +++ b/lib/libesp32/berry/src/be_debuglib.c @@ -167,6 +167,7 @@ static int m_counters(bvm *vm) map_insert(vm, "call", vm->counter_call); map_insert(vm, "get", vm->counter_get); map_insert(vm, "set", vm->counter_set); + map_insert(vm, "getgbl", vm->counter_get_global); map_insert(vm, "try", vm->counter_try); map_insert(vm, "raise", vm->counter_exc); map_insert(vm, "objects", vm->counter_gc_kept); diff --git a/lib/libesp32/berry/src/be_vm.c b/lib/libesp32/berry/src/be_vm.c index eb2b6ef63..4c21866e4 100644 --- a/lib/libesp32/berry/src/be_vm.c +++ b/lib/libesp32/berry/src/be_vm.c @@ -507,6 +507,7 @@ BERRY_API bvm* be_vm_new(void) vm->counter_call = 0; vm->counter_get = 0; vm->counter_set = 0; + vm->counter_get_global = 0; vm->counter_try = 0; vm->counter_exc = 0; vm->counter_gc_kept = 0; @@ -579,6 +580,9 @@ newframe: /* a new call frame */ dispatch(); } opcase(GETNGBL): { /* get Global by name */ +#if BE_USE_PERF_COUNTERS + vm->counter_get_global++; +#endif bvalue *v = RA(); bvalue *b = RKB(); if (var_isstr(b)) { diff --git a/lib/libesp32/berry/src/be_vm.h b/lib/libesp32/berry/src/be_vm.h index 1e83c912f..711d96ed1 100644 --- a/lib/libesp32/berry/src/be_vm.h +++ b/lib/libesp32/berry/src/be_vm.h @@ -114,6 +114,7 @@ struct bvm { uint32_t counter_call; /* counter for calls, VM or native */ uint32_t counter_get; /* counter for GETMBR or GETMET */ uint32_t counter_set; /* counter for SETMBR */ + uint32_t counter_get_global; /* counter for GETNBGL */ uint32_t counter_try; /* counter for `try` statement */ uint32_t counter_exc; /* counter for raised exceptions */ uint32_t counter_gc_kept; /* counter for objects scanned by last gc */