Add timing method that returns a value
This commit is contained in:
		
							parent
							
								
									e213b3ea26
								
							
						
					
					
						commit
						326543c0f6
					
				|  | @ -12,4 +12,13 @@ public static class Timing | ||||||
|         watch.Stop(); |         watch.Stop(); | ||||||
|         Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}"); |         Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}"); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public static T TimeStage<T>(string stagename, Func<T> action) | ||||||
|  |     { | ||||||
|  |         var watch = Stopwatch.StartNew(); | ||||||
|  |         var value = action(); | ||||||
|  |         watch.Stop(); | ||||||
|  |         Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}"); | ||||||
|  |         return value; | ||||||
|  |     } | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue