00001
00002
00006 #ifndef _RTXBENCH_H_
00007 #define _RTXBENCH_H_
00008
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 #ifndef _WIN32_WCE
00012 #define __need_timespec
00013 #include <time.h>
00014 #ifndef _NUCLEUS
00015 #include <sys/stat.h>
00016 #endif
00017 #else
00018 #include "rtxsrc/wceAddon.h"
00019 #endif
00020 #include "rtxsrc/rtxDiag.h"
00021
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025
00026 #define ITERCNT 10000L
00027
00028 typedef struct {
00029 clock_t timediff;
00030 double avgMSec;
00031 } OSRTBenchmarkTimes;
00032
00033 typedef struct {
00034 const char* program;
00035 const char* encRules;
00036 size_t itercnt;
00037 size_t msgSize;
00038 unsigned long encodeMsecs;
00039 unsigned long decodeMsecs;
00040 } OSRTBenchmarkData;
00041
00042
00043
00044
00045 #define DECLARE_BENCHMARK \
00046 struct timespec tp0, tp1, tp2, tp3; \
00047 long __clk__ = 0; \
00048 double __maxms__ = 0, __minms__ = 10000000000000.f;
00049
00050 #define CLOCK_START \
00051 clock_gettime(CLOCK_REALTIME, &tp0);
00052
00053 #define CLOCK_STOP \
00054 clock_gettime(CLOCK_REALTIME, &tp1);
00055
00056 #define BEGIN_LOOP \
00057 CLOCK_START \
00058 for (__clk__ = 0; __clk__ < ITERCNT; __clk__ ++) { \
00059 clock_gettime(CLOCK_REALTIME, &tp2);
00060
00061 #define END_LOOP \
00062 clock_gettime(CLOCK_REALTIME, &tp3); \
00063 long _dst = tp3.tv_sec - tp2.tv_sec, \
00064 _dnt = tp3.tv_nsec - tp2.tv_nsec; \
00065 double _dmst = (_dst * 1000.f) + (_dnt / 1e6); \
00066 \
00067 if (_dmst < __minms__) __minms__ = _dmst; \
00068 if (_dmst > __maxms__) __maxms__ = _dmst; \
00069 } \
00070 CLOCK_STOP
00071
00072 #define PRINT_RESULTS_MS \
00073 long _ds = tp1.tv_sec - tp0.tv_sec, \
00074 _dn = tp1.tv_nsec - tp0.tv_nsec; \
00075 double _dms = (_ds * 1000.f) + (_dn / 1e6); \
00076 printf ("\t%.6f\t%.6f\t%.6f\t%.6f\n", _dms, __minms__, __maxms__, \
00077 _dms/(float)ITERCNT);
00078
00089 double rtxBenchAverageMS (clock_t start, clock_t finish, double icnt);
00090
00091 void rtxBenchPrintResults
00092 (const char* filename, const OSRTBenchmarkData* pdata);
00093
00094 #ifdef __cplusplus
00095 }
00096 #endif
00097 #endif