Home | History | Annotate | Download | only in libbridge
      1 /*
      2  * dspbridge/src/api/linux/Timer.c
      3  *
      4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
      5  *
      6  * Copyright (C) 2007 Texas Instruments, Inc.
      7  *
      8  * This program is free software; you can redistribute it and/or modify it
      9  * under the terms of the GNU Lesser General Public License as published
     10  * by the Free Software Foundation version 2.1 of the License.
     11  *
     12  * This program is distributed .as is. WITHOUT ANY WARRANTY of any kind,
     13  * whether express or implied; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Lesser General Public License for more details.
     16  */
     17 
     18 
     19 /*
     20  *  ======== Timer.c ========
     21  *  Description:
     22  *      Source for API time measurements. For Debugging only
     23  *
     24  *
     25  *! Revision History
     26  *! =================
     27  *! 01-May-2008 RG: Initial version
     28  *
     29  */
     30 
     31 /*  ----------------------------------- Host OS */
     32 #include <perfutils.h>
     33 
     34 
     35 /*
     36  * ======== StartTimer ========
     37  */
     38 INT getTimeStamp(struct timeval *tv)
     39 {
     40 	INT Result = 0;
     41 	struct timezone tz;
     42 	Result = gettimeofday(tv, &tz);
     43 	if (Result != 0)
     44 		fprintf(stdout, "FAIL: gettimeofday is failed\n");
     45 
     46 	return Result;
     47 }
     48 /*
     49  * ======== PrintStatisticsStartTimer ========
     50  */
     51 void PrintStatistics(struct timeval *tv_beg, struct timeval *tv_end,
     52 			char *ModuleName, INT BufferSize)
     53 {
     54 	ULONG   totalTimeuSec = 0;
     55 
     56 	if (tv_end->tv_usec < tv_beg->tv_usec) {
     57 		tv_end->tv_usec += 1000000;
     58 		tv_end->tv_sec  -= 1;
     59 	}
     60 
     61 	totalTimeuSec = (tv_end->tv_sec - tv_beg->tv_sec) * 1000000 +
     62 			(tv_end->tv_usec - tv_beg->tv_usec);
     63 	fprintf(stdout, "LOG: *********BEGIN STATISTICS************"
     64 				"********************\n");
     65 	fprintf(stdout, "LOG: MODULE: %s \n", ModuleName);
     66 	if (BufferSize != 0)
     67 		fprintf(stdout, "LOG: BufferSize: 0x%x \n", BufferSize);
     68 
     69 	fprintf(stdout, "LOG: RESULT: %lu\n", totalTimeuSec);
     70 	fprintf(stdout, "LOG: **********END STATISTICS*************"
     71 				"******************\n");
     72 
     73 }
     74