Skip to content

Conversation

arcanericky
Copy link
Contributor

  • Remove use of variables that aren't really needed in InitCode
  • Eliminate the use of strings.Builder overhead
    • Also removes import of strings package
    • Speeds execution of buildSchema by 35%+
    • Significant decreased memory usage by buildSchema

The refinement of buildSchema is probably not really useful when
used from a command line utility, but if someone was to use this
package as part of a REST API or other utility that performs this
work repeatedly, it helps with memory use and runtime overhead.

The output of benchcmp:

benchmark                 old ns/op     new ns/op     delta
Benchmark_buildSchema     200           125           -37.49%

benchmark                 old allocs     new allocs     delta
Benchmark_buildSchema     4              1              -75.00%

benchmark                 old bytes     new bytes     delta
Benchmark_buildSchema     120           48            -60.00%

Function used for benchmarking:

func Benchmark_buildSchema(b *testing.B) {
	cfg := Config{
		SSID:       "testssid",
		Key:        "testkeytestkey",
		Encryption: "WPA2",
		Hidden:     false,
	}

	for i := 0; i < b.N; i++ {
		buildSchema(&cfg)
	}
}

@reugn reugn merged commit badf90f into reugn:develop Nov 17, 2021
@arcanericky arcanericky deleted the refinements branch November 18, 2021 14:05
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