Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
3f54283a
Commit
3f54283a
authored
Nov 10, 2013
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce time.Duration in Profiler function signature.
parent
ed799862
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
trace.go
trace.go
+3
-2
trace_test.go
trace_test.go
+4
-3
No files found.
trace.go
View file @
3f54283a
...
...
@@ -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.
...
...
trace_test.go
View file @
3f54283a
...
...
@@ -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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment