目的:
本实验演示了如何使用VxWorks下的timex()函数来计算一个程序执行的时间。
语法:
void timex(FUNCPTR function_name, int arg1, .., int arg8)
注意: timex函数的第一是参数是指向将被计时的程序的函数指针
实验原理:
#include "vxworks.h" /* Always include this as the first thing in every program */
#include "timexLib.h"
#include "stdio.h"
#define ITERATIONS 200
int printit (void);
void timing ()
{
/* Function to perfrom the timing */
FUNCPTR function_ptr = print;
timex(function_ptr, NULL,NULL,NULL,NULL,NULL,NULL,NULL); /* Timing the "print" function */
}
int print(void) /* Function being timed */
{
int i;
for(i=0; i<ITERATIONS; i++) /* printing the task id number and the increment Variable "i" */
printf("Hello, I am task %d and is i = %d\n", taskIdSelf(), i);
return 0;
}