
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
github.com/idasilva/profiling-samples
Some samples implementations to illustrate how to use Go Profiling to improve a Go code.
This project has three implementations with issues performance common in a Go code.
Simple implementation that will do a unmarshall multiple times as defined on param.
GET /json/unmarshall?times={times}
func Unmarshall[T any](times int) (result T) {
file, err := os.ReadFile(fmt.Sprintf("%stest.json", Path))
if err != nil {
panic(err)
}
for i := 0; i <= times; i++ {
err = json.NewDecoder(bytes.NewReader(file)).Decode(&result)
if err != nil {
panic(err)
}
}
return
}
Simple implementation that will load a location with tz multiple times as defined on param.
GET /timezone?times={times}
func Timezone(times int) (tz *time.Location) {
for i := 0; i <= times; i++ {
var err error
tz, err = time.LoadLocation("America/Sao_Paulo")
if err != nil {
panic(err)
}
}
return
}
Simple implementation that will create an object and append on slice and iterate it multiple times as defined on param.
GET /aloc?times={times}
func Aloc[O any, T []O](obj O, times int) (result T) {
for i := 0; i <= times; i++ {
result = append(result, obj)
}
for _, o := range result {
fmt.Printf("%+v\n", o)
}
return
}
On this project we will use the HTTP pkg to run the pprof.
First we will start the app.
go run .
To generate the pprof data and render it on a web page we have to execute passing the expected endpoint available with follow args:
go tool pprof -http=localhost: http://localhost:7777/debug/pprof/profile?seconds=60
Now for the pprof data has some metrics we have to simulate some parallel requests immediately after run the pprof.
curl "http://localhost:7777/json/unmarshall?times=10000000" &
curl "http://localhost:7777/timezone?times=100000" &
curl "http://localhost:7777/aloc?times=1000000" &
After 60 seconds we have to be redirected to a web page as below:
https://youtu.be/hmD9zBjuc74 "Go tool pprof web interactive"
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
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.