github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/sync2/runtime2/pid_test.go (about)

     1  package runtime2
     2  
     3  import (
     4  	"runtime"
     5  	"testing"
     6  )
     7  
     8  func BenchmarkRuntimePID(b *testing.B) {
     9  	for i := 0; i < b.N; i++ {
    10  		_ = runtime_pid()
    11  	}
    12  }
    13  
    14  func TestAsmPID(t *testing.T) {
    15  	t.Skip("crash")
    16  	for i := 0; i < 100; i++ {
    17  		if int(asm_pid()) != runtime_pid() {
    18  			t.Fatalf("%v %v", int(asm_pid()), runtime_pid())
    19  		}
    20  		runtime.Gosched()
    21  	}
    22  }
    23  
    24  func BenchmarkAsmPID(b *testing.B) {
    25  	b.Skip("crash")
    26  	for i := 0; i < b.N; i++ {
    27  		_ = asm_pid()
    28  	}
    29  }
    30  
    31  func BenchmarkRDTSCPPID(b *testing.B) {
    32  	for i := 0; i < b.N; i++ {
    33  		_ = rdtscp_pid()
    34  	}
    35  }
    36  
    37  func BenchmarkRDPID(b *testing.B) {
    38  	b.Skip("unsupported")
    39  	for i := 0; i < b.N; i++ {
    40  		_ = rdpid_pid()
    41  	}
    42  }
    43  
    44  func BenchmarkCPUIDPID(b *testing.B) {
    45  	for i := 0; i < b.N; i++ {
    46  		_ = cpuid_pid()
    47  	}
    48  }