| Server IP : 217.160.0.212 / Your IP : 216.73.217.33 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go/src/net/http/pprof/testdata/ |
Upload File : |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This binary collects a 1s delta mutex profile and dumps it to os.Stdout.
//
// This is in a subprocess because we want the base mutex profile to be empty
// (as a regression test for https://go.dev/issue/64566) and the only way to
// force reset the profile is to create a new subprocess.
//
// This manually collects the HTTP response and dumps to stdout in order to
// avoid any flakiness around port selection for a real HTTP server.
package main
import (
"bytes"
"fmt"
"log"
"net/http"
"net/http/pprof"
"net/http/httptest"
"runtime"
)
func main() {
// Disable the mutex profiler. This is the default, but that default is
// load-bearing for this test, which needs the base profile to be empty.
runtime.SetMutexProfileFraction(0)
h := pprof.Handler("mutex")
req := httptest.NewRequest("GET", "/debug/pprof/mutex?seconds=1", nil)
rec := httptest.NewRecorder()
rec.Body = new(bytes.Buffer)
h.ServeHTTP(rec, req)
resp := rec.Result()
if resp.StatusCode != http.StatusOK {
log.Fatalf("Request failed: %s\n%s", resp.Status, rec.Body)
}
fmt.Print(rec.Body)
}