* When NIX_SHOW_STATS=1, show the amount of stack space consumed by
the Nix expression evaluator.
This commit is contained in:
		
							parent
							
								
									363e307fd3
								
							
						
					
					
						commit
						adce01a8d0
					
				
					 1 changed files with 10 additions and 2 deletions
				
			
		|  | @ -362,8 +362,14 @@ Expr autoCallFunction(Expr e, const ATermMap & args) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | static char * deepestStack = (char *) -1; /* for measuring stack usage */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| Expr evalExpr2(EvalState & state, Expr e) | Expr evalExpr2(EvalState & state, Expr e) | ||||||
| { | { | ||||||
|  |     char x; | ||||||
|  |     if (&x < deepestStack) deepestStack = &x; | ||||||
|  |      | ||||||
|     Expr e1, e2, e3, e4; |     Expr e1, e2, e3, e4; | ||||||
|     ATerm name, pos; |     ATerm name, pos; | ||||||
|     AFun sym = ATgetAFun(e); |     AFun sym = ATgetAFun(e); | ||||||
|  | @ -752,12 +758,14 @@ extern "C" { | ||||||
| 
 | 
 | ||||||
| void printEvalStats(EvalState & state) | void printEvalStats(EvalState & state) | ||||||
| { | { | ||||||
|  |     char x; | ||||||
|     bool showStats = getEnv("NIX_SHOW_STATS", "0") != "0"; |     bool showStats = getEnv("NIX_SHOW_STATS", "0") != "0"; | ||||||
|     printMsg(showStats ? lvlInfo : lvlDebug, |     printMsg(showStats ? lvlInfo : lvlDebug, | ||||||
|         format("evaluated %1% expressions, %2% cache hits, %3%%% efficiency, used %4% ATerm bytes") |         format("evaluated %1% expressions, %2% cache hits, %3%%% efficiency, used %4% ATerm bytes, used %5% bytes of stack space") | ||||||
|         % state.nrEvaluated % state.nrCached |         % state.nrEvaluated % state.nrCached | ||||||
|         % ((float) state.nrCached / (float) state.nrEvaluated * 100) |         % ((float) state.nrCached / (float) state.nrEvaluated * 100) | ||||||
|         % AT_calcAllocatedSize()); |         % AT_calcAllocatedSize() | ||||||
|  |         % (&x - deepestStack)); | ||||||
|     if (showStats) |     if (showStats) | ||||||
|         printATermMapStats(); |         printATermMapStats(); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue