Add statistic for max expr node evaluations per line.

This commit is contained in:
Dianne Skoll
2025-09-11 12:04:32 -04:00
parent adb38fe82e
commit 565bca4380
4 changed files with 14 additions and 6 deletions

View File

@@ -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:

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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