Commit 3f54283a authored by gwenn's avatar gwenn

Introduce time.Duration in Profiler function signature.

parent ed799862
......@@ -27,6 +27,7 @@ import "C"
import (
"fmt"
"time"
"unsafe"
)
......@@ -59,7 +60,7 @@ func (c *Conn) Trace(f Tracer, udp interface{}) {
}
// See Conn.Profile
type Profiler func(udp interface{}, sql string, nanoseconds uint64) // TODO time.Duration
type Profiler func(udp interface{}, sql string, duration time.Duration)
type sqliteProfile struct {
f Profiler
......@@ -69,7 +70,7 @@ type sqliteProfile struct {
//export goXProfile
func goXProfile(udp unsafe.Pointer, sql *C.char, nanoseconds C.sqlite3_uint64) {
arg := (*sqliteProfile)(udp)
arg.f(arg.udp, C.GoString(sql), uint64(nanoseconds))
arg.f(arg.udp, C.GoString(sql), time.Duration(int64(nanoseconds)))
}
// Profile registers or clears a profile function.
......
......@@ -9,6 +9,7 @@ import (
"github.com/bmizerany/assert"
. "github.com/gwenn/gosqlite"
"testing"
"time"
)
func init() {
......@@ -57,11 +58,11 @@ func authorizer(d interface{}, action Action, arg1, arg2, dbName, triggerName st
return AuthOk
}
func profile(d interface{}, sql string, nanoseconds uint64) {
func profile(d interface{}, sql string, duration time.Duration) {
if t, ok := d.(*testing.T); ok {
t.Logf("PROFILE: %s = %d µs\n", sql, nanoseconds/1e3)
t.Logf("PROFILE: %s = %s\n", sql, duration)
} else {
fmt.Printf("%s: %s = %d µs\n", d, sql, nanoseconds/1e3)
fmt.Printf("%s: %s = %s\n", d, sql, duration)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment