Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
780f555b
Commit
780f555b
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
Add new alloc metric: peak_bytes_allocated.
This is just max value of current_bytes_allocated seen.
parent
02de0c57
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/malloc.c
+10
-0
10 additions, 0 deletions
py/malloc.c
py/misc.h
+1
-0
1 addition, 0 deletions
py/misc.h
with
11 additions
and
0 deletions
py/malloc.c
+
10
−
0
View file @
780f555b
...
...
@@ -5,6 +5,9 @@
static
int
total_bytes_allocated
=
0
;
static
int
current_bytes_allocated
=
0
;
static
int
peak_bytes_allocated
=
0
;
#define UPDATE_PEAK() { if (current_bytes_allocated > peak_bytes_allocated) peak_bytes_allocated = current_bytes_allocated; }
void
*
m_malloc
(
int
num_bytes
)
{
if
(
num_bytes
==
0
)
{
...
...
@@ -17,6 +20,7 @@ void *m_malloc(int num_bytes) {
}
total_bytes_allocated
+=
num_bytes
;
current_bytes_allocated
+=
num_bytes
;
UPDATE_PEAK
();
return
ptr
;
}
...
...
@@ -31,6 +35,7 @@ void *m_malloc0(int num_bytes) {
}
total_bytes_allocated
+=
num_bytes
;
current_bytes_allocated
+=
num_bytes
;
UPDATE_PEAK
();
return
ptr
;
}
...
...
@@ -52,6 +57,7 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) {
int
diff
=
new_num_bytes
-
old_num_bytes
;
total_bytes_allocated
+=
diff
;
current_bytes_allocated
+=
diff
;
UPDATE_PEAK
();
return
ptr
;
}
...
...
@@ -69,3 +75,7 @@ int m_get_total_bytes_allocated(void) {
int
m_get_current_bytes_allocated
(
void
)
{
return
current_bytes_allocated
;
}
int
m_get_peak_bytes_allocated
(
void
)
{
return
peak_bytes_allocated
;
}
This diff is collapsed.
Click to expand it.
py/misc.h
+
1
−
0
View file @
780f555b
...
...
@@ -33,6 +33,7 @@ void m_free(void *ptr, int num_bytes);
int
m_get_total_bytes_allocated
(
void
);
int
m_get_current_bytes_allocated
(
void
);
int
m_get_peak_bytes_allocated
(
void
);
/** unichar / UTF-8 *********************************************/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment