Skip to content

Conversation

@adcondev
Copy link
Owner

This change refactors anonymous functions used for generating test data in pkg/commands/printposition/print_position_test.go and pkg/commands/print/print_test.go.

New utility helpers GenerateSequence and AppendByte were added to internal/testutils/byte_helpers.go to facilitate this refactoring. These helpers improve test readability and allow for code reuse across different test packages.

The changes were verified by running go test -v -race on the affected packages.


PR created automatically by Jules for task 17895285534756257738 started by @adcondev

Extract anonymous functions in `pkg/commands/printposition/print_position_test.go`
and `pkg/commands/print/print_test.go` to utility helpers in `internal/testutils`.

- Added `GenerateSequence(n int) []byte` to `internal/testutils/byte_helpers.go`.
- Added `AppendByte(c byte) *BufferBuilder` to `BufferBuilder` in `internal/testutils/byte_helpers.go`.
- Updated tests to use these new helpers and `BufferBuilder`.
- Removed `FIXME` comments related to anonymous functions.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link
Contributor

👋 Thanks for opening this PR, @adcondev!

Here's what will happen next:

  • 🤖 Automated checks will run
  • 🏷️ Labels will be added automatically
  • 👀 A maintainer will review your changes

Please make sure:

  • ✅ All tests pass
  • 📝 The PR title follows conventional commits
  • 📋 The PR template is filled out completely

@github-actions
Copy link
Contributor

⚡ Benchmark Results

📈 Performance Comparison

📊 Click to expand detailed results

Current Branch Results

BenchmarkNewDocument-4    	1000000000	         0.3120 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3656070	       327.0 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  416229	      2728 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  533570	      2081 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  495145	      2326 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	   92724	     12669 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  424437	      2775 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  269970	      4206 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  523908	      2148 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  238156	      4801 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 8717635	       136.7 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 6579652	       178.3 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	364434674	         3.269 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	31017990	        39.06 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	14449736	        83.78 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  502160	      2389 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  138198	      8488 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     597	   1993351 ns/op	 3469936 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     328	   3682001 ns/op	 5481086 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     136	   8715539 ns/op	 5235276 B/op	  230723 allocs/op

Base Branch Results

BenchmarkNewDocument-4    	1000000000	         0.3139 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3662294	       331.2 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  413599	      2732 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  534867	      2082 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  503325	      2331 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	   94339	     12768 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  410091	      2704 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  275745	      4177 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  529047	      2198 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  217345	      4787 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 7614511	       157.1 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 6447009	       185.1 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	296139643	         4.052 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	32458162	        37.09 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	14309014	        82.93 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  499053	      2400 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  139066	      8595 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     607	   1969619 ns/op	 3469936 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     331	   3667027 ns/op	 5481088 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     139	   8707061 ns/op	 5231179 B/op	  230423 allocs/op

💡 Note: Use benchstat for statistical comparison

🎯 Summary

  • Total Benchmarks: 32
  • Average Speed: 2621580 ns/op
  • Average Memory: 2396933 B/op
  • Average Allocations: 41093 allocs/op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant