MCPcopy Create free account
hub / github.com/klauspost/cpuid / TestExample

Function TestExample

cpuid_test.go:50–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestExample(t *testing.T) {
51 Detect()
52 // Print basic CPU information:
53 fmt.Println("Name:", CPU.BrandName)
54 fmt.Println("PhysicalCores:", CPU.PhysicalCores)
55 fmt.Println("ThreadsPerCore:", CPU.ThreadsPerCore)
56 fmt.Println("LogicalCores:", CPU.LogicalCores)
57 fmt.Println("Family", CPU.Family, "Model:", CPU.Model, "Vendor ID:", CPU.VendorID)
58 fmt.Println("Features:", strings.Join(CPU.FeatureSet(), ","))
59 fmt.Println("Cacheline bytes:", CPU.CacheLine)
60 fmt.Println("L1 Data Cache:", CPU.Cache.L1D, "bytes")
61 fmt.Println("L1 Instruction Cache:", CPU.Cache.L1D, "bytes")
62 fmt.Println("L2 Cache:", CPU.Cache.L2, "bytes")
63 fmt.Println("L3 Cache:", CPU.Cache.L3, "bytes")
64 fmt.Println("Frequency", CPU.Hz, "hz")
65
66 // Test if we have these specific features:
67 if CPU.Supports(SSE, SSE2) {
68 fmt.Println("We have Streaming SIMD 2 Extensions")
69 }
70}
71func TestDumpCPUID(t *testing.T) {
72 n := int(maxFunctionID())
73 for i := 0; i <= n; i++ {

Callers

nothing calls this directly

Calls 3

DetectFunction · 0.85
FeatureSetMethod · 0.80
SupportsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…