/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2005-2007 Colin Leroy <colin@colino.net> & the Claws Mail team
+ * Copyright (C) 2005-2012 Colin Leroy <colin@colino.net> & the Claws Mail 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
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/*
#ifndef __TIMING_H__
#define __TIMING_H__
+#include <glib.h>
#include <sys/time.h>
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "claws-features.h"
#endif
#include "utils.h"
#define START_TIMING(str) do {} while(0);
#define END_TIMING() do {} while(0);
#else
+
+#ifdef G_OS_WIN32
+
+#include <w32lib.h>
+
+/* no {} by purpose */
+#define START_TIMING(str) \
+ LARGE_INTEGER frequency; \
+ LARGE_INTEGER start; \
+ LARGE_INTEGER end; \
+ LARGE_INTEGER diff; \
+ const char *timing_name=str; \
+ QueryPerformanceFrequency (&frequency); \
+ QueryPerformanceCounter (&start);
+
+#define END_TIMING() \
+ QueryPerformanceCounter (&end); \
+ diff.QuadPart = \
+ (end.QuadPart - start.QuadPart) \
+ * 1000000/frequency.QuadPart; \
+ debug_print("TIMING %s: %ds%03dms\n", timing_name, \
+ (unsigned int) (diff.QuadPart / 1000000), \
+ (unsigned int) ((diff.QuadPart / 1000) % 1000));
+
+#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); \
+ gettimeofday(&start, NULL);
#ifdef __GLIBC__
#define END_TIMING() \
debug_print("TIMING %s %s: %ds%03dms\n", \
__FUNCTION__, \
timing_name, (unsigned int)diff.tv_sec, \
- (unsigned int)diff.tv_usec/1000);
+ (unsigned int)diff.tv_usec/1000);
#else
#define END_TIMING() \
gettimeofday(&end, NULL); \
#endif
#endif
+#endif