More debugging features, performance and macOS update.

Added function name to the output of verbose logging.  Verbose logging is
the feature introduced in the previous git commit where a call to printf()
automatically adds the source filename and line from where the printf() is
called, and the runtime timestamp at which the call was made.  Now this
feature adds the functio name from which the printf() is called.  This
feature is enabled if and only if both DEBUG and VERBOSE are defined in
debug.h and the source is compiled with GCC.

Added a new macro DEBUG_PRINTF() that expands to printf() if and only if
DEBUG is defined in debug.h.  This feature works with verbose logging if
VERBOSE is also defined and the source is compiled with GCC.

Reduced the launch time.  A user reported an issue with Tux Paint taking 7
minutes to launch; an investigation showed that launching Tux Paint with
all stamps and the screen width set wide (~1500 pixels) can cause the
slowdown during the progress bar drawing sequence because progress bar
takes a long time to draw on screens with a wide screen, and it is called
~10 thousand times during the stamp loading process.  The issue has been
addressed by calling the progress bar less frequently.

Updated the macOS build version and date, under which these features were
tested.
This commit is contained in:
Mark Kim 2018-09-24 23:00:04 -04:00
parent c2be35f1bf
commit 8d9e187cc9
3 changed files with 37 additions and 7 deletions

View file

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>tuxpaint</string>
<key>CFBundleGetInfoString</key>
<string>0.9.23, Copyright 2009-2018, Tux Paint Development Team</string>
<string>0.9.23a, Copyright 2009-2018, Tux Paint Development Team</string>
<key>CFBundleIconFile</key>
<string>tuxpaint.icns</string>
<key>CFBundleIdentifier</key>
@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.23</string>
<string>0.9.23a</string>
<key>CFBundleSignature</key>
<string>TXPT</string>
<key>CFBundleVersion</key>
<string>2018-09-01</string>
<string>2018-09-24</string>
</dict>
</plist>

View file

@ -13,7 +13,34 @@
#define printf(args...) do { \
time_t now = time(NULL); \
printf("\n### %s, %d @ %s", __FILE__, __LINE__, ctime(&now)); \
printf("\n### %s, line %d in %s() @ %s", __FILE__, __LINE__, __FUNCTION__, ctime(&now)); \
printf(args); \
} while(0)
#endif
/*
* Define a convenience macro DEBUG_PRINTF(). This macro resolves to printf()
* if and only if DEBUG is enabled, otherwise resolves to nothing. In other
* words,
*
* DEBUG_PRINTF("Hello, world!\n");
*
* ... is equivalent to:
*
* #if defined(DEBUG)
* printf("Hello, world!\n");
* #endif
*
* (To be precise, the semicolon falls outside of the #if test, but an empty
* semicolon resolves to nothing in standard C.)
*
* If VERBOSE logging is enabled, DEBUG_PRINTF should resolve to the verbose
* version of printf() defined earlier in this file.
*/
#if defined(DEBUG)
#define DEBUG_PRINTF(...) printf(__VA_ARGS__)
#else
#define DEBUG_PRINTF(...)
#endif

View file

@ -7419,7 +7419,7 @@ static void loadstamp_callback(SDL_Surface * screen,
(void)locale;
#ifdef DEBUG
/* FIXME: Stderr instead of stdout? */
printf("loadstamp_callback: %s\n", dir);
printf("loadstamp_callback (%d): %s\n", i, dir);
#endif
if (num_stamps[stamp_group] > 0)
@ -7459,7 +7459,6 @@ static void loadstamp_callback(SDL_Surface * screen,
/* Sort and iterate the file list: */
qsort(files, i, sizeof *files, compare_ftw_str);
while (i--)
{
@ -7505,7 +7504,11 @@ static void loadstamp_callback(SDL_Surface * screen,
}
#endif
show_progress_bar(screen);
/*
* Showing the progress bar across the screen can be CPU-intensive, so
* update infrequently.
*/
if((i % 32) == 0) show_progress_bar(screen);
if (dotext > files[i].str && !strcasecmp(dotext, ext)
&& (dotext - files[i].str + 1 + dirlen < (int) (sizeof fname))