Skip to content

Commit 24bcb4f

Browse files
committed
[CONTRIB] halog: minor speed improvement in timer parser
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)
1 parent abe45b6 commit 24bcb4f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

contrib/halog/halog.c

+13-7
Original file line numberDiff line numberDiff line change
@@ -502,17 +502,19 @@ int main(int argc, char **argv)
502502
}
503503

504504
e = field_stop(b + 1);
505-
/* we have field TIME_FIELD in [b]..[e-1] */
505+
/* we have field TIME_FIELD in [b]..[e-1], let's check only the response time */
506506

507507
p = b;
508508
err = 0;
509-
for (f = 0; f < 4 && *p; f++) {
509+
f = 0;
510+
while (*p) {
510511
tps = str2ic(p);
511512
if (tps < 0) {
512513
tps = -1;
513514
err = 1;
514515
}
515-
516+
if (++f == 4)
517+
break;
516518
SKIP_CHAR(p, '/');
517519
}
518520

@@ -577,13 +579,15 @@ int main(int argc, char **argv)
577579

578580
p = b;
579581
err = 0;
580-
for (f = 0; f < 5 && *p; f++) {
582+
f = 0;
583+
while (*p) {
581584
array[f] = str2ic(p);
582585
if (array[f] < 0) {
583586
array[f] = -1;
584587
err = 1;
585588
}
586-
589+
if (++f == 5)
590+
break;
587591
SKIP_CHAR(p, '/');
588592
}
589593

@@ -740,13 +744,15 @@ int main(int argc, char **argv)
740744

741745
p = b;
742746
err = 0;
743-
for (f = 0; f < 5 && *p; f++) {
747+
f = 0;
748+
while (*p) {
744749
array[f] = str2ic(p);
745750
if (array[f] < 0) {
746751
array[f] = -1;
747752
err = 1;
748753
}
749-
754+
if (++f == 5)
755+
break;
750756
SKIP_CHAR(p, '/');
751757
}
752758

0 commit comments

Comments
 (0)