-ansi -pedantic fixes.
[cacao.git] / statistics.c
index e2241bd1fd673c7bfc39cc863a58e35bbdfb8a29..9ce305fdb8d2d87bedfe01d3ded7a1cfa011b87e 100644 (file)
@@ -27,7 +27,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: statistics.c 1224 2004-06-30 19:13:37Z twisti $
+   $Id: statistics.c 1438 2004-11-05 09:52:49Z twisti $
 
 */
 
 #include "global.h"
 #include "statistics.h"
 #include "toolbox/logging.h"
+#include "options.h"
 
 
 /* global variables */
 
-s8 loadingtime = 0;
-s8 compilingtime = 0;                   /* accumulated compile time           */
+static s8 loadingtime = 0;              /* accumulated loading time           */
+static s8 loadingstarttime = 0;
+static s8 loadingstoptime = 0;
+static s4 loadingtime_recursion = 0;
+
+static s8 compilingtime = 0;            /* accumulated compile time           */
+static s8 compilingstarttime = 0;
+static s8 compilingstoptime = 0;
+static s4 compilingtime_recursion = 0;
+
+s4 memoryusage = 0;
+s4 maxmemusage = 0;
+s4 maxdumpsize = 0;
+
+s4 globalallocateddumpsize = 0;
+s4 globaluseddumpsize = 0;
 
 int count_class_infos = 0;              /* variables for measurements         */
 int count_const_pool_len = 0;
 int count_vftbl_len = 0;
 int count_all_methods = 0;
+int count_methods_marked_used = 0;  /* RTA */
+
 int count_vmcode_len = 0;
 int count_extable_len = 0;
 int count_class_loads = 0;
@@ -152,6 +169,70 @@ s8 getcputime()
 }
 
 
+/* loadingtime_stop ************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void loadingtime_start()
+{
+       loadingtime_recursion++;
+
+       if (loadingtime_recursion == 1)
+               loadingstarttime = getcputime();
+}
+
+
+/* loadingtime_stop ************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void loadingtime_stop()
+{
+       if (loadingtime_recursion == 1) {
+               loadingstoptime = getcputime();
+               loadingtime += (loadingstoptime - loadingstarttime);
+       }
+
+       loadingtime_recursion--;
+}
+
+
+/* compilingtime_stop **********************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void compilingtime_start()
+{
+       compilingtime_recursion++;
+
+       if (compilingtime_recursion == 1)
+               compilingstarttime = getcputime();
+}
+
+
+/* compilingtime_stop **********************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void compilingtime_stop()
+{
+       if (compilingtime_recursion == 1) {
+               compilingstoptime = getcputime();
+               compilingtime += (compilingstoptime - compilingstarttime);
+       }
+
+       compilingtime_recursion--;
+}
+
+
 /* print_times *****************************************************************
 
    Prints a summary of CPU time usage.
@@ -212,6 +293,10 @@ void print_stats()
        log_text(logtext);
        sprintf(logtext, "Number of compiled Methods: %d", count_methods);
        log_text(logtext);
+        if (opt_rt) {
+         sprintf(logtext, "Number of Methods marked Used: %d", count_methods_marked_used);
+         log_text(logtext);
+         }
        sprintf(logtext, "Number of max basic blocks per method: %d", count_max_basic_blocks);
        log_text(logtext);
        sprintf(logtext, "Number of compiled basic blocks: %d", count_basic_blocks);
@@ -369,6 +454,28 @@ void print_stats()
 }
 
 
+/* mem_usagelog ****************************************************************
+
+   prints some memory related infos
+
+*******************************************************************************/
+
+void mem_usagelog(bool givewarnings)
+{
+       if ((memoryusage != 0) && givewarnings) {
+               dolog("Allocated memory not returned: %d", (s4) memoryusage);
+       }
+
+       if ((globalallocateddumpsize != 0) && givewarnings) {
+               dolog("Dump memory not returned: %d", (s4) globalallocateddumpsize);
+       }
+
+       dolog("Random/Dump - max. memory usage: %dkB/%dkB", 
+                 (s4) ((maxmemusage + 1023) / 1024),
+                 (s4) ((maxdumpsize + 1023) / 1024));
+}
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where