move global Name Tables

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke 2023-07-10 01:58:10 +02:00
parent 4ea61a2641
commit fff737998d
No known key found for this signature in database
2 changed files with 9 additions and 14 deletions

View File

@ -6,6 +6,14 @@ import (
"strconv"
)
// Initialize global name tables
// TODO: profiling, add option to disable name tables if necessary
// Not sure if we should resolve the names at all or just have the caller do it on demand
// (for many use cases the index is sufficient)
var CounterNameTable = *QueryNameTable("Counter 009")
var HelpNameTable = *QueryNameTable("Help 009")
func (p *perfObjectType) LookupName() string {
return CounterNameTable.LookupString(p.ObjectNameTitleIndex)
}
@ -27,7 +35,7 @@ func (t *NameTable) LookupIndex(str string) uint32 {
return t.byString[str]
}
// Query a perflib name table from the registry. Specify the type and the language
// QueryNameTable Query a perflib name table from the registry. Specify the type and the language
// code (i.e. "Counter 009" or "Help 009") for English language.
func QueryNameTable(tableName string) *NameTable {
nameTable := new(NameTable)

View File

@ -123,9 +123,6 @@ import (
// TODO: There's a LittleEndian field in the PERF header - we ought to check it
var bo = binary.LittleEndian
var CounterNameTable NameTable
var HelpNameTable NameTable
const averageCount64Type = 1073874176
// Top-level performance object (like "Process").
@ -263,16 +260,6 @@ func queryRawData(query string) ([]byte, error) {
}
}
func init() {
// Initialize global name tables
// TODO: profiling, add option to disable name tables if necessary
// Not sure if we should resolve the names at all or just have the caller do it on demand
// (for many use cases the index is sufficient)
CounterNameTable = *QueryNameTable("Counter 009")
HelpNameTable = *QueryNameTable("Help 009")
}
/*
Query all performance counters that match a given query.