Mercurial > geeqie.yaz
comparison src/main.c @ 509:b78a91d0779e
Move get_exec_time() to debug.{c,h}.
author | zas_ |
---|---|
date | Thu, 24 Apr 2008 09:43:23 +0000 |
parents | 135570a8bd96 |
children | f9bf33be53ff |
comparison
equal
deleted
inserted
replaced
508:011a6be611c8 | 509:b78a91d0779e |
---|---|
117 gdouble get_zoom_increment(void) | 117 gdouble get_zoom_increment(void) |
118 { | 118 { |
119 return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0); | 119 return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0); |
120 } | 120 } |
121 | 121 |
122 static gint timeval_delta(struct timeval *result, struct timeval *x, struct timeval *y) | |
123 { | |
124 if (x->tv_usec < y->tv_usec) | |
125 { | |
126 gint nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; | |
127 y->tv_usec -= 1000000 * nsec; | |
128 y->tv_sec += nsec; | |
129 } | |
130 | |
131 if (x->tv_usec - y->tv_usec > 1000000) | |
132 { | |
133 gint nsec = (x->tv_usec - y->tv_usec) / 1000000; | |
134 y->tv_usec += 1000000 * nsec; | |
135 y->tv_sec -= nsec; | |
136 } | |
137 | |
138 result->tv_sec = x->tv_sec - y->tv_sec; | |
139 result->tv_usec = x->tv_usec - y->tv_usec; | |
140 | |
141 return x->tv_sec < y->tv_sec; | |
142 } | |
143 | |
144 const gchar *get_exec_time() | |
145 { | |
146 static gchar timestr[30]; | |
147 static struct timeval start_tv = {0, 0}; | |
148 static struct timeval previous = {0, 0}; | |
149 static gint started = 0; | |
150 | |
151 struct timeval tv = {0, 0}; | |
152 static struct timeval delta = {0, 0}; | |
153 | |
154 gettimeofday(&tv, NULL); | |
155 | |
156 if (start_tv.tv_sec == 0) start_tv = tv; | |
157 | |
158 tv.tv_sec -= start_tv.tv_sec; | |
159 if (tv.tv_usec >= start_tv.tv_usec) | |
160 tv.tv_usec -= start_tv.tv_usec; | |
161 else | |
162 { | |
163 tv.tv_usec += 1000000 - start_tv.tv_usec; | |
164 tv.tv_sec -= 1; | |
165 } | |
166 | |
167 if (started) timeval_delta(&delta, &tv, &previous); | |
168 | |
169 previous = tv; | |
170 started = 1; | |
171 | |
172 g_snprintf(timestr, sizeof(timestr), "%5d.%06d (+%05d.%06d)", (int)tv.tv_sec, (int)tv.tv_usec, (int)delta.tv_sec, (int)delta.tv_usec); | |
173 | |
174 return timestr; | |
175 } | |
176 | 122 |
177 /* | 123 /* |
178 *----------------------------------------------------------------------------- | 124 *----------------------------------------------------------------------------- |
179 * Open browser with the help Documentation | 125 * Open browser with the help Documentation |
180 *----------------------------------------------------------------------------- | 126 *----------------------------------------------------------------------------- |
1370 CollectionData *first_collection = NULL; | 1316 CollectionData *first_collection = NULL; |
1371 gchar *geometry = NULL; | 1317 gchar *geometry = NULL; |
1372 gchar *buf; | 1318 gchar *buf; |
1373 gchar *bufl; | 1319 gchar *bufl; |
1374 | 1320 |
1375 /* init execution time counter*/ | 1321 /* init execution time counter (debug only) */ |
1376 get_exec_time(); | 1322 init_exec_time(); |
1377 | 1323 |
1378 /* setup locale, i18n */ | 1324 /* setup locale, i18n */ |
1379 gtk_set_locale(); | 1325 gtk_set_locale(); |
1380 bindtextdomain(PACKAGE, GQ_LOCALEDIR); | 1326 bindtextdomain(PACKAGE, GQ_LOCALEDIR); |
1381 bind_textdomain_codeset(PACKAGE, "UTF-8"); | 1327 bind_textdomain_codeset(PACKAGE, "UTF-8"); |