sgk / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
0 stars 0 forks source link

Create a sizeof module #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Create an objsize module to print out the sizes of the common object types.  
This will help show differences in platforms and gives an idea of the cost of 
heap use.

Original issue reported on code.google.com by dwhall...@gmail.com on 16 Apr 2009 at 7:06

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 20 Apr 2009 at 4:52

GoogleCodeExporter commented 9 years ago
Created a sizeof module.  On the desktop the results are
{{{
ipm> import sizeof
ipm> sizeof.print_sizes()
sizeof(NON) = 2
sizeof(INT) = 8
sizeof(FLT) = 8
sizeof(STR) = 12
sizeof(TUP) = 8
sizeof(COB) = 24
sizeof(MOD) = 20
sizeof(CLO) = 8
sizeof(FXN) = 20
sizeof(CLI) = 8
sizeof(CIM) = 0
sizeof(NIM) = 0
sizeof(NOB) = 24
sizeof(THR) = 12
sizeof(EXN) = 8
sizeof(BOL) = 8
sizeof(CIO) = 4
sizeof(LST) = 8
sizeof(DIC) = 12
sizeof(FRM) = 44
sizeof(BLK) = 20
sizeof(SEG) = 40
sizeof(SGL) = 16
sizeof(SQI) = 12
sizeof(NFM) = 52

ipm> sizeof.sizeof(42)
12
ipm> sizeof.sizeof(-1)
12
ipm> sizeof.sizeof(-2)
20
}}}

Notice that sizeof.print_sizes() prints the actual sizes of the structs that 
contain 
the types, but sizeof.sizeof(obj) prints the size of the chunk allocated to 
hold the 
given obj, which may vary.

Original comment by dwhall...@gmail.com on 20 Apr 2009 at 6:48

GoogleCodeExporter commented 9 years ago
Relocated #ifdef HAVE_FLOAT in float.h so that the PmFloat_t type was always 
available.

The sizeof module is NOT included in the vm build by default, you must edit 
src/vm/Makefile to add it to PMSTDLIB_SOURCES.

System tests pass.  Mainlined directly, see r351

Original comment by dwhall...@gmail.com on 20 Apr 2009 at 6:53

GoogleCodeExporter commented 9 years ago
Changed r08 to R08

Original comment by dwhall...@gmail.com on 12 Mar 2010 at 8:22

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 13 Mar 2010 at 1:30