Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
4bde5a87
Commit
4bde5a87
authored
Mar 25, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb2: add --summary and logging to tools/speed.
This helps us see where the problems are.
parent
5f388eef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
4 deletions
+66
-4
ccan/tdb2/tools/speed.c
ccan/tdb2/tools/speed.c
+66
-4
No files found.
ccan/tdb2/tools/speed.c
View file @
4bde5a87
...
...
@@ -94,15 +94,21 @@ static void dump_and_clear_stats(struct tdb_attribute_stats *stats)
memset
(
&
stats
->
allocs
,
0
,
(
char
*
)(
stats
+
1
)
-
(
char
*
)
&
stats
->
allocs
);
}
static
void
tdb_log
(
struct
tdb_context
*
tdb
,
enum
tdb_log_level
level
,
void
*
private
,
const
char
*
message
)
{
fputs
(
message
,
stderr
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
unsigned
int
i
,
j
,
num
=
1000
,
stage
=
0
,
stopat
=
-
1
;
int
flags
=
TDB_DEFAULT
;
bool
transaction
=
false
;
bool
transaction
=
false
,
summary
=
false
;
TDB_DATA
key
,
data
;
struct
tdb_context
*
tdb
;
struct
timeval
start
,
stop
;
union
tdb_attribute
seed
,
stats
;
union
tdb_attribute
seed
,
stats
,
log
;
enum
TDB_ERROR
ecode
;
/* Try to keep benchmarks even. */
...
...
@@ -110,6 +116,10 @@ int main(int argc, char *argv[])
seed
.
base
.
next
=
NULL
;
seed
.
seed
.
seed
=
0
;
log
.
base
.
attr
=
TDB_ATTRIBUTE_LOG
;
log
.
base
.
next
=
&
seed
;
log
.
log
.
log_fn
=
tdb_log
;
memset
(
&
stats
,
0
,
sizeof
(
stats
));
stats
.
base
.
attr
=
TDB_ATTRIBUTE_STATS
;
stats
.
base
.
next
=
NULL
;
...
...
@@ -130,6 +140,11 @@ int main(int argc, char *argv[])
argc
--
;
argv
++
;
}
if
(
argv
[
1
]
&&
strcmp
(
argv
[
1
],
"--summary"
)
==
0
)
{
summary
=
true
;
argc
--
;
argv
++
;
}
if
(
argv
[
1
]
&&
strcmp
(
argv
[
1
],
"--stats"
)
==
0
)
{
seed
.
base
.
next
=
&
stats
;
argc
--
;
...
...
@@ -137,7 +152,7 @@ int main(int argc, char *argv[])
}
tdb
=
tdb_open
(
"/tmp/speed.tdb"
,
flags
,
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0600
,
&
seed
);
0600
,
&
log
);
if
(
!
tdb
)
err
(
1
,
"Opening /tmp/speed.tdb"
);
...
...
@@ -173,6 +188,12 @@ int main(int argc, char *argv[])
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
@@ -197,6 +218,12 @@ int main(int argc, char *argv[])
errx
(
1
,
"committing transaction: %s"
,
tdb_errorstr
(
ecode
));
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
@@ -220,6 +247,12 @@ int main(int argc, char *argv[])
errx
(
1
,
"committing transaction: %s"
,
tdb_errorstr
(
ecode
));
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
@@ -241,6 +274,12 @@ int main(int argc, char *argv[])
errx
(
1
,
"committing transaction: %s"
,
tdb_errorstr
(
ecode
));
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
@@ -263,6 +302,12 @@ int main(int argc, char *argv[])
errx
(
1
,
"committing transaction: %s"
,
tdb_errorstr
(
ecode
));
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
@@ -285,6 +330,12 @@ int main(int argc, char *argv[])
errx
(
1
,
"committing transaction: %s"
,
tdb_errorstr
(
ecode
));
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
@@ -292,7 +343,6 @@ int main(int argc, char *argv[])
if
(
transaction
&&
(
ecode
=
tdb_transaction_start
(
tdb
)))
errx
(
1
,
"starting transaction: %s"
,
tdb_errorstr
(
ecode
));
/* Append 1000 records. */
printf
(
"Appending %u records: "
,
num
);
fflush
(
stdout
);
gettimeofday
(
&
start
,
NULL
);
...
...
@@ -305,6 +355,12 @@ int main(int argc, char *argv[])
errx
(
1
,
"committing transaction: %s"
,
tdb_errorstr
(
ecode
));
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
++
stage
==
stopat
)
exit
(
0
);
...
...
@@ -330,6 +386,12 @@ int main(int argc, char *argv[])
printf
(
" %zu ns (%zu bytes)
\n
"
,
normalize
(
&
start
,
&
stop
,
num
),
file_size
());
if
(
summary
)
{
char
*
sumstr
=
NULL
;
tdb_summary
(
tdb
,
TDB_SUMMARY_HISTOGRAMS
,
&
sumstr
);
printf
(
"%s
\n
"
,
sumstr
);
free
(
sumstr
);
}
if
(
seed
.
base
.
next
)
dump_and_clear_stats
(
&
stats
.
stats
);
if
(
++
stage
==
stopat
)
...
...
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