claws-mail/src/common/timing.h
Colin Leroy e8135a04cd 2006-05-24 [colin] 2.2.0cvs54
attention cvs users: if you manage to crash
	Sylpheed-Claws while moving, copying or deleting
	mails, we *are* interested in stack traces and
	valgrind logs. It looks stable, but one never
	knows...

	* src/folder.c
		Add progressbar for cache updates
	* src/folderutils.c
		Optimize Mark all read in the current
		folder
	* src/mh.c
		Add progressbar for copy/move
	* src/procmsg.c
		Optimize O(n^2) in copy/move
	* src/summaryview.c
	* src/gtk/gtksctree.c
		Optimize O(n^2) algos
	* src/common/timing.h
		Display ms instead of us
2006-05-24 18:02:15 +00:00

58 lines
2 KiB
C

/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 2005-2006 Colin Leroy <colin@colino.net> & the Sylpheed-Claws team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* This is a (quite naive) timer, to help determine the speed of various
* functions of Claws. By default START_TIMING() and END_TIMING() are NOPS,
* so that nothing gets printed out. If you change the #if, however, you'll
* be able to get functions timing information. As the implementation is
* naive, START_TIMING("message"); must be present just at the end of a
* declaration block (or compilation would fail with gcc 2.x), and the
* END_TIMING() call must be in the same scope.
*/
#ifndef __TIMING_H__
#define __TIMING_H__
#include <sys/time.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if 1 /* set to 0 to measure times at various places */
#define START_TIMING(str) do {} while(0);
#define END_TIMING() do {} while(0);
#else
/* no {} by purpose */
#define START_TIMING(str) \
struct timeval start; \
struct timeval end; \
struct timeval diff; \
const char *timing_name=str; \
gettimeofday(&start, NULL); \
#define END_TIMING() \
gettimeofday(&end, NULL); \
timersub(&end, &start, &diff); \
printf("%s: %ds%03dms\n", \
timing_name, (unsigned int)diff.tv_sec, \
(unsigned int)diff.tv_usec/1000); \
#endif
#endif