Skip to content

Commit 67c53f8

Browse files
authored
Merge d3d93df into c9311a4
2 parents c9311a4 + d3d93df commit 67c53f8

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/benchmark_register.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,20 @@ bool BenchmarkFamilies::FindBenchmarks(
182182
}
183183
}
184184

185-
instance.name += StrFormat("%d", arg);
185+
// we know that the args are always non-negative (see 'AddRange()'),
186+
// thus print as 'unsigned'. BUT, do a cast due to the 32-bit builds.
187+
instance.name +=
188+
StrFormat("%llu", static_cast<unsigned long long int>(arg));
186189
++arg_i;
187190
}
188191

189192
if (!IsZero(family->min_time_))
190193
instance.name += StrFormat("/min_time:%0.3f", family->min_time_);
191-
if (family->iterations_ != 0)
192-
instance.name += StrFormat("/iterations:%d", family->iterations_);
194+
if (family->iterations_ != 0) {
195+
instance.name += StrFormat(
196+
"/iterations:%llu",
197+
static_cast<unsigned long long int>(family->iterations_));
198+
}
193199
if (family->repetitions_ != 0)
194200
instance.name += StrFormat("/repeats:%d", family->repetitions_);
195201

src/string_util.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ void AppendHumanReadable(int n, std::string* str);
1212

1313
std::string HumanReadableNumber(double n, double one_k = 1024.0);
1414

15-
std::string StrFormat(const char* format, ...);
15+
#ifdef __GNUC__
16+
__attribute__((format(printf, 1, 2)))
17+
#endif
18+
std::string
19+
StrFormat(const char* format, ...);
1620

1721
inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT {
1822
return out;

test/reporter_output_test.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ ADD_CASES(TC_JSONOut,
219219
{"\"run_type\": \"iteration\",$", MR_Next}});
220220
ADD_CASES(TC_CSVOut, {{"^\"BM_arg_names/first:2/5/third:4\",%csv_report$"}});
221221

222+
// ========================================================================= //
223+
// ------------------------ Testing Big Args Output ------------------------ //
224+
// ========================================================================= //
225+
226+
void BM_BigArgs(benchmark::State& state) {
227+
for (auto _ : state) {
228+
}
229+
}
230+
BENCHMARK(BM_BigArgs)->RangeMultiplier(2)->Range(1U << 30U, 1U << 31U);
231+
ADD_CASES(TC_ConsoleOut, {{"^BM_BigArgs/1073741824 %console_report$"},
232+
{"^BM_BigArgs/2147483648 %console_report$"}});
233+
222234
// ========================================================================= //
223235
// ----------------------- Testing Complexity Output ----------------------- //
224236
// ========================================================================= //

0 commit comments

Comments
 (0)