3 #include "multicoretaskprofile.h"
5 void inittaskprofiledata() {
6 if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
7 // startup core to initialize corestatus[]
8 for(i = 0; i < NUMCORESACTIVE; ++i) {
9 // initialize the profile data arrays
11 } // for(i = 0; i < NUMCORESACTIVE; ++i)
17 taskInfoOverflow = false;
18 #ifdef PROFILE_INTERRUPT
19 interruptInfoIndex = 0;
20 interruptInfoOverflow = false;
21 #endif // PROFILE_INTERRUPT
24 // output the profiling data
25 void outputProfileData() {
28 unsigned long long totaltasktime = 0;
29 unsigned long long preprocessingtime = 0;
30 unsigned long long objqueuecheckingtime = 0;
31 unsigned long long postprocessingtime = 0;
32 unsigned long long other = 0;
33 unsigned long long averagetasktime = 0;
36 printf("Task Name, Start Time, End Time, Duration, Exit Index(, NewObj Name, Num)+\n");
37 // output task related info
38 for(i = 0; i < taskInfoIndex; i++) {
39 TaskInfo* tmpTInfo = taskInfoArray[i];
40 unsigned long long duration = tmpTInfo->endTime - tmpTInfo->startTime;
41 printf("%s, %lld, %lld, %lld, %lld", tmpTInfo->taskName,
42 tmpTInfo->startTime, tmpTInfo->endTime, duration, tmpTInfo->exitIndex);
43 // summarize new obj info
44 if(tmpTInfo->newObjs != NULL) {
45 struct RuntimeHash * nobjtbl = allocateRuntimeHash(5);
46 struct RuntimeIterator * iter = NULL;
47 while(0 == isEmpty(tmpTInfo->newObjs)) {
48 char * objtype = (char *)(getItem(tmpTInfo->newObjs));
49 if(RuntimeHashcontainskey(nobjtbl, (int)(objtype))) {
51 RuntimeHashget(nobjtbl, (int)objtype, &num);
52 RuntimeHashremovekey(nobjtbl, (int)objtype);
54 RuntimeHashadd(nobjtbl, (int)objtype, num);
56 RuntimeHashadd(nobjtbl, (int)objtype, 1);
60 // output all new obj info
61 iter = RuntimeHashcreateiterator(nobjtbl);
62 while(RunhasNext(iter)) {
63 char * objtype = (char *)Runkey(iter);
64 int num = Runnext(iter);
65 printf(", %s, %d", objtype, num);
69 if(strcmp(tmpTInfo->taskName, "tpd checking") == 0) {
70 preprocessingtime += duration;
71 } else if(strcmp(tmpTInfo->taskName, "post task execution") == 0) {
72 postprocessingtime += duration;
73 } else if(strcmp(tmpTInfo->taskName, "objqueue checking") == 0) {
74 objqueuecheckingtime += duration;
76 totaltasktime += duration;
77 averagetasktime += duration;
82 if(taskInfoOverflow) {
83 printf("Caution: task info overflow!\n");
86 other = totalexetime-totaltasktime-preprocessingtime-postprocessingtime;
87 averagetasktime /= tasknum;
89 printf("\nTotal time: %lld\n", totalexetime);
90 printf("Total task execution time: %lld (%d%%)\n", totaltasktime,
91 (int)(((double)totaltasktime/(double)totalexetime)*100));
92 printf("Total objqueue checking time: %lld (%d%%)\n",
94 (int)(((double)objqueuecheckingtime/(double)totalexetime)*100));
95 printf("Total pre-processing time: %lld (%d%%)\n", preprocessingtime,
96 (int)(((double)preprocessingtime/(double)totalexetime)*100));
97 printf("Total post-processing time: %lld (%d%%)\n", postprocessingtime,
98 (int)(((double)postprocessingtime/(double)totalexetime)*100));
99 printf("Other time: %lld (%d%%)\n", other,
100 (int)(((double)other/(double)totalexetime)*100));
102 printf("\nAverage task execution time: %lld\n", averagetasktime);
108 BAMBOO_PRINT(0xdddd);
109 // output task related info
110 for(i= 0; i < taskInfoIndex; i++) {
111 TaskInfo* tmpTInfo = taskInfoArray[i];
112 char* tmpName = tmpTInfo->taskName;
113 int nameLen = strlen(tmpName);
114 BAMBOO_PRINT(0xddda);
115 for(j = 0; j < nameLen; j++) {
116 BAMBOO_PRINT_REG(tmpName[j]);
118 BAMBOO_PRINT(0xdddb);
119 BAMBOO_PRINT_REG(tmpTInfo->startTime);
120 BAMBOO_PRINT_REG(tmpTInfo->endTime);
121 BAMBOO_PRINT_REG(tmpTInfo->exitIndex);
122 if(tmpTInfo->newObjs != NULL) {
123 struct RuntimeHash * nobjtbl = allocateRuntimeHash(5);
124 struct RuntimeIterator * iter = NULL;
125 while(0 == isEmpty(tmpTInfo->newObjs)) {
126 char * objtype = (char *)(getItem(tmpTInfo->newObjs));
127 if(RuntimeHashcontainskey(nobjtbl, (int)(objtype))) {
129 RuntimeHashget(nobjtbl, (int)objtype, &num);
130 RuntimeHashremovekey(nobjtbl, (int)objtype);
132 RuntimeHashadd(nobjtbl, (int)objtype, num);
134 RuntimeHashadd(nobjtbl, (int)objtype, 1);
138 // ouput all new obj info
139 iter = RuntimeHashcreateiterator(nobjtbl);
140 while(RunhasNext(iter)) {
141 char * objtype = (char *)Runkey(iter);
142 int num = Runnext(iter);
143 int nameLen = strlen(objtype);
144 BAMBOO_PRINT(0xddda);
145 for(j = 0; j < nameLen; j++) {
146 BAMBOO_PRINT_REG(objtype[j]);
148 BAMBOO_PRINT(0xdddb);
149 BAMBOO_PRINT_REG(num);
152 BAMBOO_PRINT(0xdddc);
155 if(taskInfoOverflow) {
156 BAMBOO_PRINT(0xefee);
159 #ifdef PROFILE_INTERRUPT
160 // output interrupt related info
161 for(i = 0; i < interruptInfoIndex; i++) {
162 InterruptInfo* tmpIInfo = interruptInfoArray[i];
163 BAMBOO_PRINT(0xddde);
164 BAMBOO_PRINT_REG(tmpIInfo->startTime);
165 BAMBOO_PRINT_REG(tmpIInfo->endTime);
166 BAMBOO_PRINT(0xdddf);
169 if(interruptInfoOverflow) {
170 BAMBOO_PRINT(0xefef);
172 #endif // PROFILE_INTERRUPT
174 BAMBOO_PRINT(0xeeee);