Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangruipeng committed Jul 25, 2019
1 parent 70161c5 commit 1dbe670
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go:
- "1.8"
- "1.9"
- "1.10"
- "1.11"
- "1.12"

script:
- make presubmit
10 changes: 5 additions & 5 deletions bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ func (d Device) DecoderUtilization() (uint, uint, error) {

// DeviceGetAccountingMode Queries process's accounting stats
// @return mode Reference in which to return the current accounting mode
func (d Device) DeviceGetAccountingMode() (C.nvmlEnableState_t, error) {
func (d Device) AccountingMode() (C.nvmlEnableState_t, error) {
var stats C.nvmlEnableState_t
if C.nvmlHandle == nil {
return stats, errLibraryNotLoaded
Expand All @@ -623,7 +623,7 @@ func (d Device) DeviceGetAccountingMode() (C.nvmlEnableState_t, error) {
// DeviceGetAccountingStats Queries process's accounting stats.
// @param pid Process Id of the target process to query stats for
// @return stats Reference in which to return the process's accounting stats
func (d Device) DeviceGetAccountingStats(pid uint) (C.nvmlAccountingStats_t, error) {
func (d Device) AccountingStats(pid uint) (C.nvmlAccountingStats_t, error) {
var stats C.nvmlAccountingStats_t
if C.nvmlHandle == nil {
return stats, errLibraryNotLoaded
Expand All @@ -636,7 +636,7 @@ func (d Device) DeviceGetAccountingStats(pid uint) (C.nvmlAccountingStats_t, err
// @param count Maxnum pids
// @return pids Pids result
// @return count Queried pids num
func (d Device) DeviceGetAccountingPids(count uint) ([]C.uint, uint, error) {
func (d Device) AccountingPids(count uint) ([]C.uint, uint, error) {
// init pids
cCount := C.uint(count)
if C.nvmlHandle == nil {
Expand All @@ -658,7 +658,7 @@ func (d Device) DeviceGetAccountingPids(count uint) ([]C.uint, uint, error) {

// DeviceGetAccountingBufferSize Returns the number of processes that the circular buffer with accounting pids can hold.
// @return buffersize buffersize
func (d Device) DeviceGetAccountingBufferSize() (uint, error) {
func (d Device) AccountingBufferSize() (uint, error) {
if C.nvmlHandle == nil {
return 0, errLibraryNotLoaded
}
Expand All @@ -672,7 +672,7 @@ func (d Device) DeviceGetAccountingBufferSize() (uint, error) {
// @param since The last query time for process
// @return utilizations The utilizations for all process
// @return processCount The queried utilizations
func (d Device) DeviceGetProcessUtilization(processCount uint, since time.Duration) ([]*Utilization, uint, error) {
func (d Device) ProcessUtilization(processCount uint, since time.Duration) ([]*Utilization, uint, error) {
if C.nvmlHandle == nil {
return nil, 0, errLibraryNotLoaded
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,28 @@ func main() {
}
fmt.Printf("\tutilization.decoder: %d\n", decoderUtilization)

modeStats, err := dev.DeviceGetAccountingMode()
modeStats, err := dev.AccountingMode()
if err != nil {
fmt.Printf("\tdev.DeviceGetAccountingMode() error: %v\n", err)
return
}
fmt.Printf("\taccounting.mode enable: %v\n", modeStats)

bufferSize, err := dev.DeviceGetAccountingBufferSize()
bufferSize, err := dev.AccountingBufferSize()
if err != nil {
fmt.Printf("\tdev.DeviceGetAccountingBufferSize() error: %v\n", err)
return
}
fmt.Printf("\taccounting.buffersize: %d\n", bufferSize)

pids, count, err := dev.DeviceGetAccountingPids(bufferSize)
pids, count, err := dev.AccountingPids(bufferSize)
if err != nil {
fmt.Printf("\tdev.DeviceGetAccountingPids() error: %v\n", err)
} else {
fmt.Printf("\taccounting.pids.count: %v\n", count)
for _, pid := range pids[:count] {
fmt.Printf("\t\tPid: %v", pid)
stats, err := dev.DeviceGetAccountingStats(uint(pid))
stats, err := dev.AccountingStats(uint(pid))
if err != nil {
fmt.Printf("\tdev.DeviceGetAccountingStats() error: %v\n", err)
} else {
Expand All @@ -168,12 +168,12 @@ func main() {
}
}

utilizations, count, err := dev.DeviceGetProcessUtilization(bufferSize, 10 * time.Second)
utilizations, count, err := dev.ProcessUtilization(bufferSize, 10*time.Second)
if err != nil {
fmt.Printf("\tdev.DeviceGetProcessUtilization() error: %v\n", err)
} else {
fmt.Printf("\tProcess count: %v\n", count)

utilizations = utilizations[:count]
for _, sample := range utilizations {
fmt.Printf("\t\tProcess: %v", sample.Pid)
Expand Down

0 comments on commit 1dbe670

Please sign in to comment.