mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Improved fb_alloc stats. (#575)
* Improved fb_alloc stats. * Fix fb_free stats.
This commit is contained in:
parent
70c00c7c83
commit
626468e87a
@ -15,6 +15,7 @@ static char *pointer = &_fballoc;
|
|||||||
static int marks = 0;
|
static int marks = 0;
|
||||||
#if defined(FB_ALLOC_STATS)
|
#if defined(FB_ALLOC_STATS)
|
||||||
static uint32_t alloc_bytes;
|
static uint32_t alloc_bytes;
|
||||||
|
static uint32_t alloc_bytes_peak;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__weak NORETURN void fb_alloc_fail()
|
__weak NORETURN void fb_alloc_fail()
|
||||||
@ -56,6 +57,7 @@ void fb_alloc_mark()
|
|||||||
marks += 1;
|
marks += 1;
|
||||||
#if defined(FB_ALLOC_STATS)
|
#if defined(FB_ALLOC_STATS)
|
||||||
alloc_bytes = 0;
|
alloc_bytes = 0;
|
||||||
|
alloc_bytes_peak = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +71,7 @@ void fb_alloc_free_till_mark()
|
|||||||
}
|
}
|
||||||
marks -= 1;
|
marks -= 1;
|
||||||
#if defined(FB_ALLOC_STATS)
|
#if defined(FB_ALLOC_STATS)
|
||||||
printf("Total allocated FB memory: %lu bytes\n", alloc_bytes);
|
printf("fb_alloc peak memory: %lu\n", alloc_bytes_peak);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +96,9 @@ void *fb_alloc(uint32_t size)
|
|||||||
pointer = new_pointer;
|
pointer = new_pointer;
|
||||||
#if defined(FB_ALLOC_STATS)
|
#if defined(FB_ALLOC_STATS)
|
||||||
alloc_bytes += size;
|
alloc_bytes += size;
|
||||||
|
if (alloc_bytes > alloc_bytes_peak) {
|
||||||
|
alloc_bytes_peak = alloc_bytes;
|
||||||
|
}
|
||||||
printf("fb_alloc %lu bytes\n", size);
|
printf("fb_alloc %lu bytes\n", size);
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
@ -125,6 +130,9 @@ void *fb_alloc_all(uint32_t *size)
|
|||||||
pointer = new_pointer;
|
pointer = new_pointer;
|
||||||
#if defined(FB_ALLOC_STATS)
|
#if defined(FB_ALLOC_STATS)
|
||||||
alloc_bytes += *size;
|
alloc_bytes += *size;
|
||||||
|
if (alloc_bytes > alloc_bytes_peak) {
|
||||||
|
alloc_bytes_peak = alloc_bytes;
|
||||||
|
}
|
||||||
printf("fb_alloc_all %lu bytes\n", *size);
|
printf("fb_alloc_all %lu bytes\n", *size);
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
@ -141,6 +149,9 @@ void *fb_alloc0_all(uint32_t *size)
|
|||||||
void fb_free()
|
void fb_free()
|
||||||
{
|
{
|
||||||
if (pointer < &_fballoc) {
|
if (pointer < &_fballoc) {
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
alloc_bytes -= *((uint32_t *) pointer);
|
||||||
|
#endif
|
||||||
pointer += *((uint32_t *) pointer); // Get size and pop.
|
pointer += *((uint32_t *) pointer); // Get size and pop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,6 +159,9 @@ void fb_free()
|
|||||||
void fb_free_all()
|
void fb_free_all()
|
||||||
{
|
{
|
||||||
while (pointer < &_fballoc) {
|
while (pointer < &_fballoc) {
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
alloc_bytes -= *((uint32_t *) pointer);
|
||||||
|
#endif
|
||||||
pointer += *((uint32_t *) pointer); // Get size and pop.
|
pointer += *((uint32_t *) pointer); // Get size and pop.
|
||||||
}
|
}
|
||||||
marks = 0;
|
marks = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user