]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CONTRIB] halog: minor speed improvement in timer parser
authorWilly Tarreau <w@1wt.eu>
Thu, 28 Oct 2010 18:39:50 +0000 (20:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 30 Oct 2010 17:04:37 +0000 (19:04 +0200)
The timer parser looks for the next slash after the last timer, which is
very far away. Those 4 occurrences have been fixed to match the way it's
done in URL sorting, which is faster. Average speed gain is 5-6% on -srv
and -pct.
(cherry picked from commit 3555671c93695f48c02ef05c8bb228523f17ca20)

contrib/halog/halog.c

index fa31b2893e8504ac0289185b7a3942f51a24a928..fa2042ccc76c2b457326157503141b6eec141592 100644 (file)
@@ -502,17 +502,19 @@ int main(int argc, char **argv)
                        }
 
                        e = field_stop(b + 1);
-                       /* we have field TIME_FIELD in [b]..[e-1] */
+                       /* we have field TIME_FIELD in [b]..[e-1], let's check only the response time */
 
                        p = b;
                        err = 0;
-                       for (f = 0; f < 4 && *p; f++) {
+                       f = 0;
+                       while (*p) {
                                tps = str2ic(p);
                                if (tps < 0) {
                                        tps = -1;
                                        err = 1;
                                }
-
+                               if (++f == 4)
+                                       break;
                                SKIP_CHAR(p, '/');
                        }
 
@@ -577,13 +579,15 @@ int main(int argc, char **argv)
 
                        p = b;
                        err = 0;
-                       for (f = 0; f < 5 && *p; f++) {
+                       f = 0;
+                       while (*p) {
                                array[f] = str2ic(p);
                                if (array[f] < 0) {
                                        array[f] = -1;
                                        err = 1;
                                }
-
+                               if (++f == 5)
+                                       break;
                                SKIP_CHAR(p, '/');
                        }
 
@@ -740,13 +744,15 @@ int main(int argc, char **argv)
 
                        p = b;
                        err = 0;
-                       for (f = 0; f < 5 && *p; f++) {
+                       f = 0;
+                       while (*p) {
                                array[f] = str2ic(p);
                                if (array[f] < 0) {
                                        array[f] = -1;
                                        err = 1;
                                }
-
+                               if (++f == 5)
+                                       break;
                                SKIP_CHAR(p, '/');
                        }