Skip to content

Commit 59fa9d2

Browse files
committed
pg_test_timing: Add NLS
Also straighten out use of time unit abbreviations a bit. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent a39255d commit 59fa9d2

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

doc/src/sgml/ref/pgtesttiming.sgml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@
9696

9797
<screen>
9898
Testing timing overhead for 3 seconds.
99-
Per loop time including overhead: 35.96 nsec
99+
Per loop time including overhead: 35.96 ns
100100
Histogram of timing durations:
101-
< usec % of total count
101+
< us % of total count
102102
1 96.40465 80435604
103103
2 3.59518 2999652
104104
4 0.00015 126
@@ -109,9 +109,9 @@ Histogram of timing durations:
109109

110110
<para>
111111
Note that different units are used for the per loop time than the
112-
histogram. The loop can have resolution within a few nanoseconds (nsec),
112+
histogram. The loop can have resolution within a few nanoseconds (ns),
113113
while the individual timing calls can only resolve down to one microsecond
114-
(usec).
114+
(us).
115115
</para>
116116

117117
</refsect2>
@@ -157,9 +157,9 @@ EXPLAIN ANALYZE SELECT COUNT(*) FROM t;
157157
tsc hpet acpi_pm
158158
# echo acpi_pm > /sys/devices/system/clocksource/clocksource0/current_clocksource
159159
# pg_test_timing
160-
Per loop time including overhead: 722.92 nsec
160+
Per loop time including overhead: 722.92 ns
161161
Histogram of timing durations:
162-
< usec % of total count
162+
< us % of total count
163163
1 27.84870 1155682
164164
2 72.05956 2990371
165165
4 0.07810 3241
@@ -170,7 +170,7 @@ Histogram of timing durations:
170170

171171
<para>
172172
In this configuration, the sample <command>EXPLAIN ANALYZE</command> above
173-
takes 115.9 ms. That's 1061 nsec of timing overhead, again a small multiple
173+
takes 115.9 ms. That's 1061 ns of timing overhead, again a small multiple
174174
of what's measured directly by this utility. That much timing overhead
175175
means the actual query itself is only taking a tiny fraction of the
176176
accounted for time, most of it is being consumed in overhead instead. In
@@ -211,7 +211,7 @@ $ pg_test_timing
211211
Testing timing overhead for 3 seconds.
212212
Per timing duration including loop overhead: 97.75 ns
213213
Histogram of timing durations:
214-
< usec % of total count
214+
< us % of total count
215215
1 90.23734 27694571
216216
2 9.75277 2993204
217217
4 0.00981 3010

src/bin/pg_test_timing/nls.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# src/bin/pg_test_timing/nls.mk
2+
CATALOG_NAME = pg_test_timing
3+
AVAIL_LANGUAGES =
4+
GETTEXT_FILES = pg_test_timing.c

src/bin/pg_test_timing/pg_test_timing.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ main(int argc, char *argv[])
2525
{
2626
uint64 loop_count;
2727

28+
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_test_timing"));
2829
progname = get_progname(argv[0]);
2930

3031
handle_args(argc, argv);
@@ -51,7 +52,7 @@ handle_args(int argc, char *argv[])
5152
{
5253
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
5354
{
54-
printf("Usage: %s [-d DURATION]\n", progname);
55+
printf(_("Usage: %s [-d DURATION]\n"), progname);
5556
exit(0);
5657
}
5758
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
@@ -71,7 +72,7 @@ handle_args(int argc, char *argv[])
7172
break;
7273

7374
default:
74-
fprintf(stderr, "Try \"%s --help\" for more information.\n",
75+
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
7576
progname);
7677
exit(1);
7778
break;
@@ -81,23 +82,26 @@ handle_args(int argc, char *argv[])
8182
if (argc > optind)
8283
{
8384
fprintf(stderr,
84-
"%s: too many command-line arguments (first is \"%s\")\n",
85+
_("%s: too many command-line arguments (first is \"%s\")\n"),
8586
progname, argv[optind]);
86-
fprintf(stderr, "Try \"%s --help\" for more information.\n",
87+
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
8788
progname);
8889
exit(1);
8990
}
9091

9192
if (test_duration > 0)
9293
{
93-
printf("Testing timing overhead for %d seconds.\n", test_duration);
94+
printf(ngettext("Testing timing overhead for %d second.\n",
95+
"Testing timing overhead for %d seconds.\n",
96+
test_duration),
97+
test_duration);
9498
}
9599
else
96100
{
97101
fprintf(stderr,
98-
"%s: duration must be a positive integer (duration is \"%d\")\n",
102+
_("%s: duration must be a positive integer (duration is \"%d\")\n"),
99103
progname, test_duration);
100-
fprintf(stderr, "Try \"%s --help\" for more information.\n",
104+
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
101105
progname);
102106
exit(1);
103107
}
@@ -133,8 +137,8 @@ test_timing(int32 duration)
133137
/* Did time go backwards? */
134138
if (diff < 0)
135139
{
136-
printf("Detected clock going backwards in time.\n");
137-
printf("Time warp: %d microseconds\n", diff);
140+
fprintf(stderr, _("Detected clock going backwards in time.\n"));
141+
fprintf(stderr, _("Time warp: %d ms\n"), diff);
138142
exit(1);
139143
}
140144

@@ -157,7 +161,7 @@ test_timing(int32 duration)
157161

158162
INSTR_TIME_SUBTRACT(end_time, start_time);
159163

160-
printf("Per loop time including overhead: %0.2f nsec\n",
164+
printf(_("Per loop time including overhead: %0.2f ns\n"),
161165
INSTR_TIME_GET_DOUBLE(end_time) * 1e9 / loop_count);
162166

163167
return loop_count;
@@ -173,8 +177,8 @@ output(uint64 loop_count)
173177
while (max_bit > 0 && histogram[max_bit] == 0)
174178
max_bit--;
175179

176-
printf("Histogram of timing durations:\n");
177-
printf("%6s %10s %10s\n", "< usec", "% of total", "count");
180+
printf(_("Histogram of timing durations:\n"));
181+
printf("%6s %10s %10s\n", _("< us"), _("% of total"), _("count"));
178182

179183
for (i = 0; i <= max_bit; i++)
180184
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy