Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
08af45f4
Commit
08af45f4
authored
Jan 17, 2011
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add getopt() support to test_fsync; also fix printf() format problem.
parent
48075095
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
18 deletions
+49
-18
src/tools/fsync/README
src/tools/fsync/README
+6
-2
src/tools/fsync/test_fsync.c
src/tools/fsync/test_fsync.c
+43
-16
No files found.
src/tools/fsync/README
View file @
08af45f4
...
@@ -3,7 +3,11 @@ test_fsync
...
@@ -3,7 +3,11 @@ test_fsync
This program tests fsync. The tests are described as part of the program output.
This program tests fsync. The tests are described as part of the program output.
Usage: test_fsync [-f filename] [ops_per_test]
Usage: test_fsync [option...]
Options:
-f, --filename specify filename for test
-o, --ops-per-test operations per test
test_fsync is intended to give you a reasonable idea of what the fastest
test_fsync is intended to give you a reasonable idea of what the fastest
fsync_method is on your specific system, as well as supplying diagnostic
fsync_method is on your specific system, as well as supplying diagnostic
...
@@ -16,6 +20,6 @@ The output filename defaults to test_fsync.out in the current directory.
...
@@ -16,6 +20,6 @@ The output filename defaults to test_fsync.out in the current directory.
test_fsync should be run in the same filesystem as your transaction log
test_fsync should be run in the same filesystem as your transaction log
directory (pg_xlog).
directory (pg_xlog).
Op
s-per-
test defaults to 2000. Increase this to get more accurate
Op
erations per
test defaults to 2000. Increase this to get more accurate
measurements.
measurements.
src/tools/fsync/test_fsync.c
View file @
08af45f4
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "postgres.h"
#include "postgres.h"
#include "getopt_long.h"
#include "access/xlog_internal.h"
#include "access/xlog_internal.h"
#include "access/xlog.h"
#include "access/xlog.h"
#include "access/xlogdefs.h"
#include "access/xlogdefs.h"
...
@@ -80,26 +81,52 @@ main(int argc, char *argv[])
...
@@ -80,26 +81,52 @@ main(int argc, char *argv[])
void
void
handle_args
(
int
argc
,
char
*
argv
[])
handle_args
(
int
argc
,
char
*
argv
[])
{
{
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"-h"
)
==
0
)
static
struct
option
long_options
[]
=
{
{
"filename"
,
required_argument
,
NULL
,
'f'
},
{
"ops-per-test"
,
required_argument
,
NULL
,
'o'
},
{
NULL
,
0
,
NULL
,
0
}
};
int
option
;
/* Command line option */
int
optindex
=
0
;
/* used by getopt_long */
if
(
argc
>
1
)
{
{
fprintf
(
stderr
,
"test_fsync [-f filename] [ops-per-test]
\n
"
);
if
(
strcmp
(
argv
[
1
],
"--help"
)
==
0
||
strcmp
(
argv
[
1
],
"-h"
)
==
0
||
exit
(
1
);
strcmp
(
argv
[
1
],
"-?"
)
==
0
)
{
fprintf
(
stderr
,
"test_fsync [-f filename] [ops-per-test]
\n
"
);
exit
(
0
);
}
if
(
strcmp
(
argv
[
1
],
"--version"
)
==
0
||
strcmp
(
argv
[
1
],
"-V"
)
==
0
)
{
fprintf
(
stderr
,
"test_fsync "
PG_VERSION
"
\n
"
);
exit
(
0
);
}
}
}
/*
while
((
option
=
getopt_long
(
argc
,
argv
,
"f:o:"
,
* arguments: ops_per_test and filename (optional)
long_options
,
&
optindex
))
!=
-
1
)
*/
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"-f"
)
==
0
)
{
{
filename
=
argv
[
2
];
switch
(
option
)
argv
+=
2
;
{
argc
-=
2
;
case
'f'
:
filename
=
strdup
(
optarg
);
break
;
case
'o'
:
ops_per_test
=
atoi
(
optarg
);
break
;
default:
fprintf
(
stderr
,
"Try
\"
%s --help
\"
for more information.
\n
"
,
"test_fsync"
);
exit
(
1
);
break
;
}
}
}
if
(
argc
>
1
)
printf
(
"%d operations per test
\n\n
"
,
ops_per_test
);
ops_per_test
=
atoi
(
argv
[
1
]);
printf
(
"Ops-per-test = %d
\n\n
"
,
ops_per_test
);
}
}
void
void
...
@@ -448,7 +475,7 @@ test_open_syncs(void)
...
@@ -448,7 +475,7 @@ test_open_syncs(void)
}
}
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
|
PG_O_DIRECT
,
0
))
==
-
1
)
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
|
PG_O_DIRECT
,
0
))
==
-
1
)
printf
(
NA_FORMAT
,
"n/a**
\n
"
);
printf
(
NA_FORMAT
,
"
o_direct"
,
"
n/a**
\n
"
);
else
else
{
{
printf
(
LABEL_FORMAT
,
"2 open_sync 8k writes"
);
printf
(
LABEL_FORMAT
,
"2 open_sync 8k writes"
);
...
...
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