tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "NormW" <no...@bocnet.com.au>
Subject PATCH \jk\native2\common\jk_worker_status.c - minimising calls to jkprintf()
Date Wed, 16 Jun 2004 10:35:07 GMT
Greetings All,

I haven't given up on a jkprint{} buffer but as an interim 'solution', the
patch below reduces calls to jkprint() in the four functions shown:
_displayStat from 10 to 4,
_displayAggregate from 8 to 5,
_displayEndpointInfo from 7 to 5,
_displayScoreboardInfo from 11 to 8,
while leaving the code quite legible.
It also supplys two missing </tr> tags and capitalises some display fields.

http://normw.gknw.com/mod_jk2/patches/jk_worker_status.c.diff

If this is acceptable will continue further.
Norm
---------------------------------------
--- jk_worker_status.c.orig 2004-05-08 07:05:53.000000000 +1000
+++ jk_worker_status.c 2004-06-16 11:12:31.000000000 +1000
@@ -52,19 +52,19 @@
     unsigned long maxTime = *maxTimeP;
     char ctimeBuf[APR_CTIME_LEN];

-    s->jkprintf(env, s, "<tr><td>%d</td><td>%d</td><td>%d</td>\n",
-                stat->workerId, stat->reqCnt, stat->errCnt);
-    s->jkprintf(env, s, "<td>%s</td>\n", JK_CHECK_NULL(stat->active));
+    s->jkprintf(env, s,
"<tr><td>%d</td><td>%d</td><td>%d</td><td>%s</td>\n",
+                stat->workerId,
+                stat->reqCnt,
+                stat->errCnt,
+                JK_CHECK_NULL(stat->active));

     totalReq += stat->reqCnt;
     totalErr += stat->errCnt;

     apr_ctime(ctimeBuf, stat->connectedTime);
-    s->jkprintf(env, s, "<td>%s</td>\n", ctimeBuf);
-
-    s->jkprintf(env, s, "<td>%ld</td>\n",
-                (long)apr_time_as_msec(stat->totalTime));
-    s->jkprintf(env, s, "<td>%ld</td>\n",
+    s->jkprintf(env, s, "<td>%s</td><td>%ld</td><td>%ld</td>\n",
+                ctimeBuf,
+                (long)apr_time_as_msec(stat->totalTime),
                 (long)apr_time_as_msec(stat->maxTime));

     if (stat->reqCnt + stat->errCnt > 0)
@@ -76,16 +76,14 @@
         s->jkprintf(env, s, "<td>-</td>\n");

     apr_ctime(ctimeBuf, stat->startTime);
-    s->jkprintf(env, s, "<td>%s</td>\n", ctimeBuf);
-    s->jkprintf(env, s, "<td>%ld</td>\n",
-                (long)apr_time_as_msec(stat->jkStartTime -
stat->startTime));
-    s->jkprintf(env, s, "<td>%ld</td>\n",
+    s->jkprintf(env, s, "<td>%s</td><td>%ld</td><td>%ld</td></tr>\n",
+                ctimeBuf,
+                (long)apr_time_as_msec(stat->jkStartTime -
stat->startTime),
                 (long)apr_time_as_msec(stat->endTime - stat->startTime));

     totalTime += (long)stat->totalTime;
     if (maxTime < stat->maxTime)
         maxTime = (long)stat->maxTime;
-    s->jkprintf(env, s, "</tr>\n");

     *maxTimeP = maxTime;
     *totalTimeP = totalTime;
@@ -104,23 +102,21 @@
     s->jkprintf(env, s, "Totals:\n");

     s->jkprintf(env, s,
-                "<table
border><tr><th>Req</th><th>Err</th><th>Max</th><th>Avg</th></tr>");
-
-    s->jkprintf(env, s, "<tr><td>%d</td>\n", totalReq);
-    s->jkprintf(env, s, "<td>%d</td>\n", totalErr);
+                "<table
border>\n<tr><th>Req</th><th>Err</th><th>Max</th><th>Avg</th></tr>");

-    s->jkprintf(env, s, "<td>%ld</td>\n", apr_time_as_msec(maxTime));
+    s->jkprintf(env, s, "<tr><td>%d</td><td>%d</td><td>%ld</td>\n",
+                totalReq,
+                totalErr,
+                apr_time_as_msec(maxTime));

     if (totalErr + totalReq > 0) {
         unsigned long avg =
             apr_time_as_msec(totalTime / (totalReq + totalErr));
-        s->jkprintf(env, s, "<td>%ld</td>\n", avg);
+        s->jkprintf(env, s, "<td>%ld</td></tr>\n</table>\n", avg);
     }
     else {
-        s->jkprintf(env, s, "<td>-</td>\n");
+        s->jkprintf(env, s, "<td>-</td></tr>\n</table>\n");
     }
-
-    s->jkprintf(env, s, "</tr></table>\n");
 }

 /** Information for the internal endpoints ( in this process ).
@@ -138,15 +134,10 @@
     unsigned long totalTime = 0;
     unsigned long maxTime = 0;

-    s->jkprintf(env, s, "<h2>Endpoint info ( no shm )</h2>\n");
-
-    s->jkprintf(env, s, "<table border>\n");
-
-    s->jkprintf(env, s, "<tr><th>Worker</th><th>Req</th><th>Err</th>");
-    s->jkprintf(env, s, "<th>LastReq</th>\n");
-    s->jkprintf(env, s,
-
"<th>ConnectionTime</th><th>TotalTime</th><th>MaxTime</th><th>AvgTime</th>")
;
-    s->jkprintf(env, s, "<th>ReqStart</th><th>+jk</th><th>+end</th>");
+    s->jkprintf(env, s, "<h2>Endpoint Info ( no shm )</h2>\n<table
border>\n");
+    s->jkprintf(env, s,
"<tr><th>Worker</th><th>Req</th><th>Err</th><th>LastReq</th>\n");
+    s->jkprintf(env, s,
"<th>ConnectionTime</th><th>TotalTime</th><th>MaxTime</th>");
+    s->jkprintf(env, s,
"<th>AvgTime</th><th>ReqStart</th><th>+JK</th><th>+End</th></tr>");

     for (i = 0; i < env->_objects->size(env, env->_objects); i++) {
         jk_bean_t *mbean = env->_objects->valueAt(env, env->_objects, i);
@@ -192,7 +183,7 @@
         return;
     }

-    s->jkprintf(env, s, "<h2>Scoreboard info (ver=%d slots=%d)</h2>\n",
+    s->jkprintf(env, s, "<h2>Scoreboard Info (Ver=%d Slots=%d)</h2>\n",
                 wenv->shm->head->lbVer, wenv->shm->head->lastSlot);

     s->jkprintf(env, s, "<a href='jkstatus?scoreboard.reset'>reset</a>\n");
@@ -209,17 +200,14 @@
             /* This is an endpoint slot */
             void *data = slot->data;

-            s->jkprintf(env, s, "<tr><th colspan='4'>%s</th>\n",
-                        JK_CHECK_NULL(slot->name));
-            s->jkprintf(env, s, "<th>Cnt=%d</th><th>size=%d</th>\n",
-                        slot->structCnt, slot->structSize);
-
-            s->jkprintf(env, s,
-                        "<tr><th>Worker</th><th>Req</th><th>Err</th>");
-            s->jkprintf(env, s, "<th>LastReq</th>\n");
-            s->jkprintf(env, s,
-
"<th>ConnectionTime</th><th>TotalTime</th><th>MaxTime</th><th>AvgTime</th>")
;
-            s->jkprintf(env, s,
"<th>ReqStart</th><th>+jk</th><th>+end</th>");
+            s->jkprintf(env, s, "<tr><th
colspan='4'>%s</th><th>Cnt=%d</th><th>size=%d</th>\n",
+                        JK_CHECK_NULL(slot->name),
+                        slot->structCnt,
+                        slot->structSize);
+
+            s->jkprintf(env, s,
"<tr><th>Worker</th><th>Req</th><th>Err</th><th>LastReq</th>\n");
+            s->jkprintf(env, s,
"<th>ConnectionTime</th><th>TotalTime</th><th>MaxTime</th>");
+            s->jkprintf(env, s,
"<th>AvgTime</th><th>ReqStart</th><th>+JK</th><th>+End</th></tr>");

             /* XXX Add info about number of slots */
             for (j = 0; j < slot->structCnt; j++) {

---------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message