Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
github.com/runnerdave/go-benchmarking-example
simple benchmarking of string concatenation functions taken from: https://www.soroushjp.com/2015/01/27/beautifully-simple-benchmarking-with-go/
jimenezd-JSS1129:benchmarking-example jimenezd$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/runnerdave/benchmarking-example
BenchmarkSelfConcatOperator1000-12 5000 272766 ns/op
BenchmarkSelfConcatBuffer1000-12 200000 7214 ns/op
BenchmarkSelfConcatOperator100000-12 1 1463489675 ns/op
BenchmarkSelfConcatBuffer100000-12 2000 636606 ns/op
PASS
ok github.com/runnerdave/benchmarking-example 5.728s
From the official Golang documentation: https://golang.org/pkg/testing/#hdr-Benchmarks
The benchmark function must run the target code b.N times. During benchmark execution, b.N is adjusted until the benchmark function lasts long enough to be timed reliably. The output
BenchmarkHello 10000000 282 ns/op
means that the loop ran 10000000 times at a speed of 282 ns per loop.
If a benchmark needs some expensive setup before running, the timer may be reset:
func BenchmarkBigLen(b *testing.B) {
big := NewBig()
b.ResetTimer()
for i := 0; i < b.N; i++ {
big.Len()
}
}
If a benchmark needs to test performance in a parallel setting, it may use the RunParallel helper function; such benchmarks are intended to be used with the go test -cpu flag:
func BenchmarkTemplateParallel(b *testing.B) {
templ := template.Must(template.New("test").Parse("Hello, {{.}}!"))
b.RunParallel(func(pb *testing.PB) {
var buf bytes.Buffer
for pb.Next() {
buf.Reset()
templ.Execute(&buf, "World")
}
})
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.