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
4d5b28cd
Commit
4d5b28cd
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
Add qstr_info() function and bindings for unix port.
parent
217814cc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/qstr.c
+16
-0
16 additions, 0 deletions
py/qstr.c
py/qstr.h
+2
-0
2 additions, 0 deletions
py/qstr.h
unix/main.c
+14
-0
14 additions, 0 deletions
unix/main.c
with
32 additions
and
0 deletions
py/qstr.c
+
16
−
0
View file @
4d5b28cd
...
...
@@ -185,3 +185,19 @@ const byte *qstr_data(qstr q, uint *len) {
*
len
=
Q_GET_LENGTH
(
qd
);
return
Q_GET_DATA
(
qd
);
}
void
qstr_pool_info
(
uint
*
n_pool
,
uint
*
n_qstr
,
uint
*
n_str_data_bytes
,
uint
*
n_total_bytes
)
{
*
n_pool
=
0
;
*
n_qstr
=
0
;
*
n_str_data_bytes
=
0
;
*
n_total_bytes
=
0
;
for
(
qstr_pool_t
*
pool
=
last_pool
;
pool
!=
NULL
&&
pool
!=
&
const_pool
;
pool
=
pool
->
prev
)
{
*
n_pool
+=
1
;
*
n_qstr
+=
pool
->
len
;
for
(
const
byte
**
q
=
pool
->
qstrs
,
**
q_top
=
pool
->
qstrs
+
pool
->
len
;
q
<
q_top
;
q
++
)
{
*
n_str_data_bytes
+=
Q_GET_ALLOC
(
*
q
);
}
*
n_total_bytes
+=
sizeof
(
qstr_pool_t
)
+
sizeof
(
qstr
)
*
pool
->
alloc
;
}
*
n_total_bytes
+=
*
n_str_data_bytes
;
}
This diff is collapsed.
Click to expand it.
py/qstr.h
+
2
−
0
View file @
4d5b28cd
...
...
@@ -36,3 +36,5 @@ machine_uint_t qstr_hash(qstr q);
const
char
*
qstr_str
(
qstr
q
);
uint
qstr_len
(
qstr
q
);
const
byte
*
qstr_data
(
qstr
q
,
uint
*
len
);
void
qstr_pool_info
(
uint
*
n_pool
,
uint
*
n_qstr
,
uint
*
n_str_data_bytes
,
uint
*
n_total_bytes
);
This diff is collapsed.
Click to expand it.
unix/main.c
+
14
−
0
View file @
4d5b28cd
...
...
@@ -216,6 +216,18 @@ int usage(void) {
return
1
;
}
mp_obj_t
mem_info
(
void
)
{
printf
(
"mem: total=%d, current=%d, peak=%d
\n
"
,
m_get_total_bytes_allocated
(),
m_get_current_bytes_allocated
(),
m_get_peak_bytes_allocated
());
return
mp_const_none
;
}
mp_obj_t
qstr_info
(
void
)
{
uint
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
;
qstr_pool_info
(
&
n_pool
,
&
n_qstr
,
&
n_str_data_bytes
,
&
n_total_bytes
);
printf
(
"qstr pool: n_pool=%u, n_qstr=%u, n_str_data_bytes=%u, n_total_bytes=%u
\n
"
,
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
);
return
mp_const_none
;
}
int
main
(
int
argc
,
char
**
argv
)
{
qstr_init
();
rt_init
();
...
...
@@ -225,6 +237,8 @@ int main(int argc, char **argv) {
rt_store_attr
(
m_sys
,
MP_QSTR_argv
,
py_argv
);
rt_store_name
(
qstr_from_str
(
"test"
),
test_obj_new
(
42
));
rt_store_name
(
qstr_from_str
(
"mem_info"
),
rt_make_function_n
(
0
,
mem_info
));
rt_store_name
(
qstr_from_str
(
"qstr_info"
),
rt_make_function_n
(
0
,
qstr_info
));
file_init
();
rawsocket_init
();
...
...
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