mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 10:47:27 +08:00 
			
		
		
		
	pkg/proc: Reset time after continue in benchmarks
Reset the timer once we start executing the code paths we actually care to measure, since the setup and continue steps can be relatively expensive. Also, disable recording on benchmarks. This seems less useful, and also cuts out a lot of noise when benchmarks are run.
This commit is contained in:
		 Derek Parker
					Derek Parker
				
			
				
					committed by
					
						 Alessandro Arzilli
						Alessandro Arzilli
					
				
			
			
				
	
			
			
			 Alessandro Arzilli
						Alessandro Arzilli
					
				
			
						parent
						
							c4fd80fcd0
						
					
				
				
					commit
					475551cf3d
				
			| @ -1445,10 +1445,10 @@ func TestBreakpointCounts(t *testing.T) { | |||||||
|  |  | ||||||
| func BenchmarkArray(b *testing.B) { | func BenchmarkArray(b *testing.B) { | ||||||
| 	// each bencharr struct is 128 bytes, bencharr is 64 elements long | 	// each bencharr struct is 128 bytes, bencharr is 64 elements long | ||||||
| 	protest.AllowRecording(b) |  | ||||||
| 	b.SetBytes(int64(64 * 128)) | 	b.SetBytes(int64(64 * 128)) | ||||||
| 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | ||||||
| 		assertNoError(proc.Continue(p), b, "Continue()") | 		assertNoError(proc.Continue(p), b, "Continue()") | ||||||
|  | 		b.ResetTimer() | ||||||
| 		for i := 0; i < b.N; i++ { | 		for i := 0; i < b.N; i++ { | ||||||
| 			evalVariable(p, b, "bencharr") | 			evalVariable(p, b, "bencharr") | ||||||
| 		} | 		} | ||||||
| @ -1518,10 +1518,10 @@ func TestBreakpointCountsWithDetection(t *testing.T) { | |||||||
| func BenchmarkArrayPointer(b *testing.B) { | func BenchmarkArrayPointer(b *testing.B) { | ||||||
| 	// each bencharr struct is 128 bytes, benchparr is an array of 64 pointers to bencharr | 	// each bencharr struct is 128 bytes, benchparr is an array of 64 pointers to bencharr | ||||||
| 	// each read will read 64 bencharr structs plus the 64 pointers of benchparr | 	// each read will read 64 bencharr structs plus the 64 pointers of benchparr | ||||||
| 	protest.AllowRecording(b) |  | ||||||
| 	b.SetBytes(int64(64*128 + 64*8)) | 	b.SetBytes(int64(64*128 + 64*8)) | ||||||
| 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | ||||||
| 		assertNoError(proc.Continue(p), b, "Continue()") | 		assertNoError(proc.Continue(p), b, "Continue()") | ||||||
|  | 		b.ResetTimer() | ||||||
| 		for i := 0; i < b.N; i++ { | 		for i := 0; i < b.N; i++ { | ||||||
| 			evalVariable(p, b, "bencharr") | 			evalVariable(p, b, "bencharr") | ||||||
| 		} | 		} | ||||||
| @ -1532,10 +1532,10 @@ func BenchmarkMap(b *testing.B) { | |||||||
| 	// m1 contains 41 entries, each one has a value that's 2 int values (2* 8 bytes) and a string key | 	// m1 contains 41 entries, each one has a value that's 2 int values (2* 8 bytes) and a string key | ||||||
| 	// each string key has an average of 9 character | 	// each string key has an average of 9 character | ||||||
| 	// reading strings and the map structure imposes a overhead that we ignore here | 	// reading strings and the map structure imposes a overhead that we ignore here | ||||||
| 	protest.AllowRecording(b) |  | ||||||
| 	b.SetBytes(int64(41 * (2*8 + 9))) | 	b.SetBytes(int64(41 * (2*8 + 9))) | ||||||
| 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | ||||||
| 		assertNoError(proc.Continue(p), b, "Continue()") | 		assertNoError(proc.Continue(p), b, "Continue()") | ||||||
|  | 		b.ResetTimer() | ||||||
| 		for i := 0; i < b.N; i++ { | 		for i := 0; i < b.N; i++ { | ||||||
| 			evalVariable(p, b, "m1") | 			evalVariable(p, b, "m1") | ||||||
| 		} | 		} | ||||||
| @ -1543,9 +1543,9 @@ func BenchmarkMap(b *testing.B) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func BenchmarkGoroutinesInfo(b *testing.B) { | func BenchmarkGoroutinesInfo(b *testing.B) { | ||||||
| 	protest.AllowRecording(b) |  | ||||||
| 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | 	withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { | ||||||
| 		assertNoError(proc.Continue(p), b, "Continue()") | 		assertNoError(proc.Continue(p), b, "Continue()") | ||||||
|  | 		b.ResetTimer() | ||||||
| 		for i := 0; i < b.N; i++ { | 		for i := 0; i < b.N; i++ { | ||||||
| 			p.ClearAllGCache() | 			p.ClearAllGCache() | ||||||
| 			_, _, err := proc.GoroutinesInfo(p, 0, 0) | 			_, _, err := proc.GoroutinesInfo(p, 0, 0) | ||||||
| @ -1605,11 +1605,11 @@ func TestPointerLoops(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func BenchmarkLocalVariables(b *testing.B) { | func BenchmarkLocalVariables(b *testing.B) { | ||||||
| 	protest.AllowRecording(b) |  | ||||||
| 	withTestProcess("testvariables", b, func(p *proc.Target, fixture protest.Fixture) { | 	withTestProcess("testvariables", b, func(p *proc.Target, fixture protest.Fixture) { | ||||||
| 		assertNoError(proc.Continue(p), b, "Continue() returned an error") | 		assertNoError(proc.Continue(p), b, "Continue() returned an error") | ||||||
| 		scope, err := proc.GoroutineScope(p.CurrentThread()) | 		scope, err := proc.GoroutineScope(p.CurrentThread()) | ||||||
| 		assertNoError(err, b, "Scope()") | 		assertNoError(err, b, "Scope()") | ||||||
|  | 		b.ResetTimer() | ||||||
| 		for i := 0; i < b.N; i++ { | 		for i := 0; i < b.N; i++ { | ||||||
| 			_, err := scope.LocalVariables(normalLoadConfig) | 			_, err := scope.LocalVariables(normalLoadConfig) | ||||||
| 			assertNoError(err, b, "LocalVariables()") | 			assertNoError(err, b, "LocalVariables()") | ||||||
| @ -2667,7 +2667,6 @@ func TestIssue664(t *testing.T) { | |||||||
|  |  | ||||||
| // Benchmarks (*Processs).Continue + (*Scope).FunctionArguments | // Benchmarks (*Processs).Continue + (*Scope).FunctionArguments | ||||||
| func BenchmarkTrace(b *testing.B) { | func BenchmarkTrace(b *testing.B) { | ||||||
| 	protest.AllowRecording(b) |  | ||||||
| 	withTestProcess("traceperf", b, func(p *proc.Target, fixture protest.Fixture) { | 	withTestProcess("traceperf", b, func(p *proc.Target, fixture protest.Fixture) { | ||||||
| 		setFunctionBreakpoint(p, b, "main.PerfCheck") | 		setFunctionBreakpoint(p, b, "main.PerfCheck") | ||||||
| 		b.ResetTimer() | 		b.ResetTimer() | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user