============== idProgram::CompileStats called after all files are compiled to report memory usage. ============== */
| 1774 | ============== |
| 1775 | */ |
| 1776 | void idProgram::CompileStats( void ) { |
| 1777 | int memused; |
| 1778 | int memallocated; |
| 1779 | int stringspace; |
| 1780 | int funcMem; |
| 1781 | int i; |
| 1782 | |
| 1783 | gameLocal.Printf( "----- Compile stats -----\n" ); |
| 1784 | gameLocal.DPrintf( "Files loaded:\n" ); |
| 1785 | |
| 1786 | stringspace = 0; |
| 1787 | for( i = 0; i < fileList.Num(); i++ ) { |
| 1788 | gameLocal.DPrintf( " %s\n", fileList[ i ].c_str() ); |
| 1789 | stringspace += fileList[ i ].Allocated(); |
| 1790 | } |
| 1791 | stringspace += fileList.Size(); |
| 1792 | |
| 1793 | memused = varDefs.Num() * sizeof( idVarDef ); |
| 1794 | memused += types.Num() * sizeof( idTypeDef ); |
| 1795 | memused += stringspace; |
| 1796 | |
| 1797 | for( i = 0; i < types.Num(); i++ ) { |
| 1798 | memused += types[ i ]->Allocated(); |
| 1799 | } |
| 1800 | |
| 1801 | funcMem = functions.MemoryUsed(); |
| 1802 | for( i = 0; i < functions.Num(); i++ ) { |
| 1803 | funcMem += functions[ i ].Allocated(); |
| 1804 | } |
| 1805 | |
| 1806 | memallocated = funcMem + memused + sizeof( idProgram ); |
| 1807 | |
| 1808 | memused += statements.MemoryUsed(); |
| 1809 | memused += functions.MemoryUsed(); // name and filename of functions are shared, so no need to include them |
| 1810 | memused += sizeof( variables ); |
| 1811 | |
| 1812 | gameLocal.Printf( "Memory usage:\n" ); |
| 1813 | gameLocal.Printf( " Strings: %d, %d bytes\n", fileList.Num(), stringspace ); |
| 1814 | gameLocal.Printf( " Statements: %d, %zd bytes\n", statements.Num(), statements.MemoryUsed() ); |
| 1815 | gameLocal.Printf( " Functions: %d, %d bytes\n", functions.Num(), funcMem ); |
| 1816 | gameLocal.Printf( " Variables: %d bytes\n", numVariables ); |
| 1817 | gameLocal.Printf( " Mem used: %d bytes\n", memused ); |
| 1818 | gameLocal.Printf( " Static data: %zd bytes\n", sizeof( idProgram ) ); |
| 1819 | gameLocal.Printf( " Allocated: %d bytes\n", memallocated ); |
| 1820 | gameLocal.Printf( " Thread size: %zd bytes\n", sizeof( idThread ) ); |
| 1821 | } |
| 1822 | |
| 1823 | /* |
| 1824 | ================ |