Added execution time functions for win32
authorjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Jul 2003 15:38:14 +0000 (15:38 +0000)
committerjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Jul 2003 15:38:14 +0000 (15:38 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2774 4a8a32a2-be11-0410-ad9d-d568d2c75423

as/mcs51/lkmain.c
link/z80/lkmain.c

index cc695c9bc2f730d6a281065e1d8fbb00b8695395..842bcb33f8427e0e7a288c9dd0922cb1800e6e44 100644 (file)
 #include <string.h>
 #include "aslink.h"
 
+#ifdef WIN32T
+#include <time.h>
+
+void Timer(int action, char * message)
+{
+       static double start, end, total=0.0;
+    static const double secs_per_tick = 1.0 / CLOCKS_PER_SEC;
+
+    if(action==0) start=clock()*secs_per_tick;
+    else if(action==1)
+    {
+       end=clock() * secs_per_tick;
+               printf("%s \t%f seconds.\n", message, (end-start));
+               total+=end-start;
+    }
+    else
+    {
+               printf("Total time: \t%f seconds.\n", total);
+               total=0.0;
+    }
+}
+#endif
+
 /* yuck - but including unistd.h causes problems on Cygwin by redefining
  * Addr_T.
  */
@@ -176,6 +199,10 @@ char *argv[];
        register char *p;
        register int c, i;
 
+#ifdef WIN32T
+    Timer(0, "");
+#endif
+
        startp = (struct lfile *) new (sizeof (struct lfile));
 
        pflag = 1;
@@ -344,6 +371,10 @@ char *argv[];
        //JCF:
        CreateAOMF51();
 
+#ifdef WIN32T
+    Timer(1, "Linker execution time");
+#endif
+
        lkexit(lkerr);
        return 0;
 }
index 745504b8495c52eac4e17914b8c009e08610c404..cf1b4745e765d5b121dd20905d6ea75920d489ec 100644 (file)
 #define TARGET_STRING          "gbz80"
 #endif
 
+#ifdef WIN32T
+#include <time.h>
+
+void Timer(int action, char * message)
+{
+       static double start, end, total=0.0;
+    static const double secs_per_tick = 1.0 / CLOCKS_PER_SEC;
+
+    if(action==0) start=clock()*secs_per_tick;
+    else if(action==1)
+    {
+       end=clock() * secs_per_tick;
+               printf("%s \t%f seconds.\n", message, (end-start));
+               total+=end-start;
+    }
+    else
+    {
+               printf("Total time: \t%f seconds.\n", total);
+               total=0.0;
+    }
+}
+#endif
+
 /*)Module      lkmain.c
  *
  *     The module lkmain.c contains the functions which
@@ -165,6 +188,10 @@ char *argv[];
        register char *p;
        register int c, i;
 
+#ifdef WIN32T
+    Timer(0, "");
+#endif
+
 #ifdef GAMEBOY
        nb_rom_banks = 2;
        nb_ram_banks = 0;
@@ -376,6 +403,9 @@ char *argv[];
                        reloc('E');
                }
        }
+#ifdef WIN32T
+    Timer(1, "Linker time");
+#endif
        lkexit(lkerr);
 
         /* Never get here. */