move global Name Tables
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
parent
4ea61a2641
commit
fff737998d
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue