forked from absolute8511/gorocksdb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
perf_context.go
54 lines (45 loc) · 1.13 KB
/
perf_context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package gorocksdb
// #include "rocksdb/c.h"
// #include "gorocksdb.h"
import "C"
import "unsafe"
type PerfLevel int
const (
PerfUnknown PerfLevel = iota
PerfDisable = 1
PerfEnableCount = 2
PerfEnableTimeExceptForMutex = 3
PerfEnableTime = 4
)
func SetPerfLevel(level PerfLevel) {
C.rocksdb_set_perf_level(C.int(level))
}
type PerfContext struct {
c *C.rocksdb_perfcontext_t
}
// refill_period_us default to 100*1000
// fairness default to 10
func NewPerfContext() *PerfContext {
c := C.rocksdb_perfcontext_create()
return &PerfContext{c}
}
// Destroy deallocates the BlockBasedTableOptions object.
func (pf *PerfContext) Reset() {
C.rocksdb_perfcontext_reset(pf.c)
}
func (pf *PerfContext) Report(excludeZero bool) string {
exclude := C.uchar(0)
if excludeZero {
exclude = C.uchar(1)
}
cValue := C.rocksdb_perfcontext_report(pf.c, exclude)
if cValue == nil {
return ""
}
defer C.free(unsafe.Pointer(cValue))
return C.GoString(cValue)
}
func (pf *PerfContext) Destroy() {
C.rocksdb_perfcontext_destroy(pf.c)
pf.c = nil
}