Skip to content

Commit

Permalink
Update printf format specifiers
Browse files Browse the repository at this point in the history
Can't find any format specifier that works portably for int64_t (PRId64
is problematic on MSYS) so just use long longs instead.
  • Loading branch information
jbytheway committed Jun 18, 2019
1 parent 75a9215 commit a58d755
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
9 changes: 5 additions & 4 deletions tests/line_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <inttypes.h>
#include <time.h>
#include <chrono>
#include <cstdio>
Expand Down Expand Up @@ -332,14 +333,14 @@ static void line_to_comparison( const int iterations )
const auto end2 = std::chrono::high_resolution_clock::now();

if( iterations > 1 ) {
const int64_t diff1 =
const long long diff1 =
std::chrono::duration_cast<std::chrono::microseconds>( end1 - start1 ).count();
const int64_t diff2 =
const long long diff2 =
std::chrono::duration_cast<std::chrono::microseconds>( end2 - start2 ).count();

printf( "line_to() executed %d times in %ld microseconds.\n",
printf( "line_to() executed %d times in %lld microseconds.\n",
iterations, diff1 );
printf( "canonical_line_to() executed %d times in %ld microseconds.\n",
printf( "canonical_line_to() executed %d times in %lld microseconds.\n",
iterations, diff2 );
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/map_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ TEST_CASE( "lru_cache_perf", "[.]" )
}
}
const auto end1 = std::chrono::high_resolution_clock::now();
const int64_t diff1 = std::chrono::duration_cast<std::chrono::microseconds>
( end1 - start1 ).count();
printf( "completed %d insertions in %ld microseconds.\n", max_size, diff1 );
const long long diff1 = std::chrono::duration_cast<std::chrono::microseconds>
( end1 - start1 ).count();
printf( "completed %d insertions in %lld microseconds.\n", max_size, diff1 );
/*
* Original tripoint hash completed 1000000 insertions in 96136925 microseconds.
* Table based interleave v1 completed 1000000 insertions in 41435604 microseconds.
Expand Down
32 changes: 16 additions & 16 deletions tests/shadowcasting_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ static void shadowcasting_runoff( const int iterations, const bool test_bresenha
const auto end2 = std::chrono::high_resolution_clock::now();

if( iterations > 1 ) {
const int64_t diff1 = std::chrono::duration_cast<std::chrono::microseconds>
( end1 - start1 ).count();
const int64_t diff2 = std::chrono::duration_cast<std::chrono::microseconds>
( end2 - start2 ).count();
printf( "oldCastLight() executed %d times in %ld microseconds.\n",
const long long diff1 = std::chrono::duration_cast<std::chrono::microseconds>
( end1 - start1 ).count();
const long long diff2 = std::chrono::duration_cast<std::chrono::microseconds>
( end2 - start2 ).count();
printf( "oldCastLight() executed %d times in %lld microseconds.\n",
iterations, diff1 );
printf( "castLight() executed %d times in %ld microseconds.\n",
printf( "castLight() executed %d times in %lld microseconds.\n",
iterations, diff2 );
}

Expand Down Expand Up @@ -318,15 +318,15 @@ static void shadowcasting_float_quad(
const auto end2 = std::chrono::high_resolution_clock::now();

if( iterations > 1 ) {
const int64_t diff1 = std::chrono::duration_cast<std::chrono::microseconds>
( end1 - start1 ).count();
const int64_t diff2 = std::chrono::duration_cast<std::chrono::microseconds>
( end2 - start2 ).count();
const long long diff1 = std::chrono::duration_cast<std::chrono::microseconds>
( end1 - start1 ).count();
const long long diff2 = std::chrono::duration_cast<std::chrono::microseconds>
( end2 - start2 ).count();
printf( "castLight on four_quadrants (denominator %u) "
"executed %d times in %ld microseconds.\n",
"executed %d times in %lld microseconds.\n",
denominator, iterations, diff1 );
printf( "castLight on floats (denominator %u) "
"executed %d times in %ld microseconds.\n",
"executed %d times in %lld microseconds.\n",
denominator, iterations, diff2 );
}

Expand Down Expand Up @@ -383,13 +383,13 @@ static void shadowcasting_3d_2d( const int iterations )
const auto end2 = std::chrono::high_resolution_clock::now();

if( iterations > 1 ) {
const int64_t diff1 =
const long long diff1 =
std::chrono::duration_cast<std::chrono::microseconds>( end1 - start1 ).count();
const int64_t diff2 =
const long long diff2 =
std::chrono::duration_cast<std::chrono::microseconds>( end2 - start2 ).count();
printf( "castLight() executed %d times in %ld microseconds.\n",
printf( "castLight() executed %d times in %lld microseconds.\n",
iterations, diff1 );
printf( "cast_zlight() executed %d times in %ld microseconds.\n",
printf( "cast_zlight() executed %d times in %lld microseconds.\n",
iterations, diff2 );
printf( "new/old execution time ratio: %.02f.\n", static_cast<double>( diff2 ) / diff1 );
}
Expand Down

0 comments on commit a58d755

Please sign in to comment.