Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cam-stitt
Copy link
Contributor

@cam-stitt cam-stitt commented Feb 26, 2022

The efficiency of ExecuteBlocks was pretty poor. This improves it by:

  • Only visiting the parent if it has a block that is being sought after
  • When we first try to render a block in a template, rather then when we first visit the template
    • Assign the buffer
    • Assign the context

The results were pretty staggering, specifically when passing an empty block array, or when working on deeply nested inheritance.

// When passing empty blocks
// Original
BenchmarkExecuteBlocksWithEmptyBlocksSandboxActive-6   	  675499	      1746 ns/op	     952 B/op	       9 allocs/op
// New
BenchmarkExecuteBlocksWithEmptyBlocksSandboxActive-6   	26332879	        44.17 ns/op	      48 B/op	       1 allocs/op

// When passing blocks
// Original
BenchmarkExecuteBlocksWithoutSandbox-6   	  687286	      1792 ns/op	    1261 B/op	      12 allocs/op
// New
BenchmarkExecuteBlocksWithoutSandbox-6   	  690864	      1763 ns/op	    1261 B/op	      12 allocs/op

// With very deep inheritance
// Original
BenchmarkExecuteBlocksDeepWithSandboxActive-6   	  158157	      7230 ns/op	    3920 B/op	      35 allocs/op
// New
BenchmarkExecuteBlocksDeepWithSandboxActive-6   	  304110	      3950 ns/op	    2192 B/op	      21 allocs/op

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@cam-stitt
Copy link
Contributor Author

@flosch would love to get this PR wrapped up if possible 😄

@flosch
Copy link
Owner

flosch commented Jun 23, 2022

Thanks for your improvements.

@flosch flosch merged commit f244d20 into flosch:master Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants