From 78852f092b0e5cf1150eccb3151aa4d07c1273cc Mon Sep 17 00:00:00 2001 From: jesusc Date: Fri, 25 Jul 2003 15:38:14 +0000 Subject: [PATCH] Added execution time functions for win32 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2774 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- as/mcs51/lkmain.c | 31 +++++++++++++++++++++++++++++++ link/z80/lkmain.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/as/mcs51/lkmain.c b/as/mcs51/lkmain.c index cc695c9b..842bcb33 100644 --- a/as/mcs51/lkmain.c +++ b/as/mcs51/lkmain.c @@ -19,6 +19,29 @@ #include #include "aslink.h" +#ifdef WIN32T +#include + +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; } diff --git a/link/z80/lkmain.c b/link/z80/lkmain.c index 745504b8..cf1b4745 100644 --- a/link/z80/lkmain.c +++ b/link/z80/lkmain.c @@ -25,6 +25,29 @@ #define TARGET_STRING "gbz80" #endif +#ifdef WIN32T +#include + +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. */ -- 2.30.2