diff --git a/src/expr.c b/src/expr.c index 32026b3c..a9defe8a 100644 --- a/src/expr.c +++ b/src/expr.c @@ -894,7 +894,9 @@ evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst) } ExpressionNodesEvaluated++; ExpressionNodesEvaluatedThisLine++; - + if (ExpressionNodesEvaluatedThisLine > MaxExprNodesPerLine) { + MaxExprNodesPerLine = ExpressionNodesEvaluatedThisLine; + } switch(node->type) { case N_FREE: case N_ERROR: diff --git a/src/globals.h b/src/globals.h index c27944a9..6f51d528 100644 --- a/src/globals.h +++ b/src/globals.h @@ -89,6 +89,7 @@ EXTERN INIT( int RunDisabled, 0); EXTERN INIT( int ExpressionEvaluationDisabled, 0); EXTERN INIT( int ExpressionEvaluationTimeLimit, 0); EXTERN INIT( int ExpressionNodesEvaluated, 0); +EXTERN INIT( int MaxExprNodesPerLine, 0); EXTERN INIT( int ExpressionNodesEvaluatedThisLine, 0); EXTERN INIT( int ExpressionNodeLimitPerLine, 0); EXTERN INIT( volatile sig_atomic_t ExpressionTimeLimitExceeded, 0); diff --git a/src/main.c b/src/main.c index 9bb37501..20fd6124 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,8 @@ exitfunc(void) UnsetAllUserFuncs(); print_expr_nodes_stats(); - fprintf(ErrFp, "Total expression node evaluations: %d\n", ExpressionNodesEvaluated); + fprintf(ErrFp, "Max expr node evaluations per line: %d\n", MaxExprNodesPerLine); + fprintf(ErrFp, "Total expression node evaluations: %d\n", ExpressionNodesEvaluated); } } diff --git a/tests/test.cmp b/tests/test.cmp index 8b780fc5..6f9ec75a 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -16667,7 +16667,8 @@ Translation hash table statistics: Expression nodes high-water: 302076 Expression nodes leaked: 0 Parse level high-water: 34 -Total expression node evaluations: 106467 +Max expr node evaluations per line: 2001 +Total expression node evaluations: 106467 Test 2 @@ -24290,7 +24291,8 @@ Translation hash table statistics: Expression nodes high-water: 499 Expression nodes leaked: 0 Parse level high-water: 2001 -Total expression node evaluations: 632 +Max expr node evaluations per line: 499 +Total expression node evaluations: 632 -stdin-(14): Unmatched PUSH-OMIT-CONTEXT at -stdin-(7) -stdin-(14): Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT No reminders. @@ -24875,7 +24877,8 @@ Translation hash table statistics: Expression nodes high-water: 1800000 Expression nodes leaked: 0 Parse level high-water: 7 -Total expression node evaluations: 300001 +Max expr node evaluations per line: 3 +Total expression node evaluations: 300001 set a 8 * "]]]" & 6 -stdin-(1): Parse error `&' (did you mean `&&'?) 8 * "]]]" & 6 @@ -39857,4 +39860,5 @@ Translation hash table statistics: Expression nodes high-water: 16 Expression nodes leaked: 0 Parse level high-water: 25 -Total expression node evaluations: 3999940 +Max expr node evaluations per line: 1000000 +Total expression node evaluations: 3999940