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
0f3351aa
Commit
0f3351aa
authored
Aug 28, 2012
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust pg_test_timing to show shortest test durations first, place
percentage column before count column. Docs updated.
parent
65b2ee27
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
47 deletions
+59
-47
contrib/pg_test_timing/pg_test_timing.c
contrib/pg_test_timing/pg_test_timing.c
+40
-28
doc/src/sgml/pgtesttiming.sgml
doc/src/sgml/pgtesttiming.sgml
+19
-19
No files found.
contrib/pg_test_timing/pg_test_timing.c
View file @
0f3351aa
...
...
@@ -14,16 +14,24 @@ static const char *progname;
static
int32
test_duration
=
3
;
static
void
handle_args
(
int
argc
,
char
*
argv
[]);
static
void
test_timing
(
int32
);
static
uint64
test_timing
(
int32
);
static
void
output
(
uint64
loop_count
);
/* record duration in powers of 2 microseconds */
int64
histogram
[
32
];
int
main
(
int
argc
,
char
*
argv
[])
{
uint64
loop_count
;
progname
=
get_progname
(
argv
[
0
]);
handle_args
(
argc
,
argv
);
test_timing
(
test_duration
);
loop_count
=
test_timing
(
test_duration
);
output
(
loop_count
);
return
0
;
}
...
...
@@ -95,25 +103,14 @@ handle_args(int argc, char *argv[])
}
}
static
void
static
uint64
test_timing
(
int32
duration
)
{
uint64
total_time
;
int64
time_elapsed
=
0
;
uint64
loop_count
=
0
;
uint64
prev
,
cur
;
int32
diff
,
i
,
bits
,
found
;
instr_time
start_time
,
end_time
,
temp
;
static
int64
histogram
[
32
];
char
buf
[
100
];
uint64
prev
,
cur
;
instr_time
start_time
,
end_time
,
temp
;
total_time
=
duration
>
0
?
duration
*
1000000
:
0
;
...
...
@@ -122,11 +119,14 @@ test_timing(int32 duration)
while
(
time_elapsed
<
total_time
)
{
int32
diff
,
bits
=
0
;
prev
=
cur
;
INSTR_TIME_SET_CURRENT
(
temp
);
cur
=
INSTR_TIME_GET_MICROSEC
(
temp
);
diff
=
cur
-
prev
;
/* Did time go backwards? */
if
(
diff
<
0
)
{
printf
(
"Detected clock going backwards in time.
\n
"
);
...
...
@@ -134,12 +134,14 @@ test_timing(int32 duration)
exit
(
1
);
}
bits
=
0
;
/* What is the highest bit in the time diff? */
while
(
diff
)
{
diff
>>=
1
;
bits
++
;
}
/* Update appropriate duration bucket */
histogram
[
bits
]
++
;
loop_count
++
;
...
...
@@ -153,19 +155,29 @@ test_timing(int32 duration)
printf
(
"Per loop time including overhead: %0.2f nsec
\n
"
,
INSTR_TIME_GET_DOUBLE
(
end_time
)
*
1e9
/
loop_count
);
return
loop_count
;
}
static
void
output
(
uint64
loop_count
)
{
int64
max_bit
=
31
,
i
;
/* find highest bit value */
while
(
max_bit
>
0
&&
histogram
[
max_bit
]
==
0
)
max_bit
--
;
printf
(
"Histogram of timing durations:
\n
"
);
printf
(
"%
9s: %10s %9s
\n
"
,
"< usec"
,
"count"
,
"perce
nt"
);
printf
(
"%
6s %10s %10s
\n
"
,
"< usec"
,
"% of total"
,
"cou
nt"
);
found
=
0
;
for
(
i
=
31
;
i
>=
0
;
i
--
)
for
(
i
=
0
;
i
<=
max_bit
;
i
++
)
{
if
(
found
||
histogram
[
i
])
{
found
=
1
;
/* lame hack to work around INT64_FORMAT deficiencies */
snprintf
(
buf
,
sizeof
(
buf
),
INT64_FORMAT
,
histogram
[
i
]);
printf
(
"%9ld: %10s %8.5f%%
\n
"
,
1l
<<
i
,
buf
,
(
double
)
histogram
[
i
]
*
100
/
loop_count
);
}
char
buf
[
100
];
/* lame hack to work around INT64_FORMAT deficiencies */
snprintf
(
buf
,
sizeof
(
buf
),
INT64_FORMAT
,
histogram
[
i
]);
printf
(
"%6ld %9.5f %10s
\n
"
,
1l
<<
i
,
(
double
)
histogram
[
i
]
*
100
/
loop_count
,
buf
);
}
}
doc/src/sgml/pgtesttiming.sgml
View file @
0f3351aa
...
...
@@ -98,12 +98,12 @@
Testing timing overhead for 3 seconds.
Per loop time including overhead: 35.96 nsec
Histogram of timing durations:
< usec: count perce
nt
16: 2 0.00000%
8: 13 0.00002%
4: 126 0.00015%
2: 2999652 3.59518%
1: 80435604 96.40465%
< usec % of total cou
nt
1 96.40465 80435604
2 3.59518 2999652
4 0.00015 126
8 0.00002 13
16 0.00000 2
</screen>
</para>
...
...
@@ -159,12 +159,12 @@ tsc hpet acpi_pm
# pg_test_timing
Per loop time including overhead: 722.92 nsec
Histogram of timing durations:
< usec: count perce
nt
16: 3 0.00007%
8: 563 0.01357%
4: 3241 0.07810%
2: 2990371 72.05956%
1: 1155682 27.84870%
< usec % of total cou
nt
1 27.84870 1155682
2 72.05956 2990371
4 0.07810 3241
8 0.01357 563
16 0.00007 3
</screen>
</para>
...
...
@@ -206,13 +206,13 @@ $ pg_test_timing
Testing timing overhead for 3 seconds.
Per timing duration including loop overhead: 97.75 ns
Histogram of timing durations:
< usec: count perce
nt
32: 1 0.00000%
16: 1 0.00000%
8: 22 0.00007%
4: 3010 0.00981%
2: 2993204 9.75277%
1: 27694571 90.23734%
< usec % of total cou
nt
1 90.23734 27694571
2 9.75277 2993204
4 0.00981 3010
8 0.00007 22
16 0.00000 1
32 0.00000 1
</screen></para>
</refsect2>
...
...
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