1 | //======================================================================== |
2 | // |
3 | // GooTimer.cc |
4 | // |
5 | // This file is licensed under GPLv2 or later |
6 | // |
7 | // Copyright 2005 Jonathan Blandford <jrb@redhat.com> |
8 | // Copyright 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com> |
9 | // Copyright 2010 Hib Eris <hib@hiberis.nl> |
10 | // Copyright 2011 Albert Astals cid <aacid@kde.org> |
11 | // Copyright 2014 Bogdan Cristea <cristeab@gmail.com> |
12 | // Copyright 2014 Peter Breitenlohner <peb@mppmu.mpg.de> |
13 | // Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team |
14 | // |
15 | //======================================================================== |
16 | |
17 | #ifndef GOOTIMER_H |
18 | #define GOOTIMER_H |
19 | |
20 | #include "poppler-config.h" |
21 | #include "poppler_private_export.h" |
22 | |
23 | #ifdef HAVE_GETTIMEOFDAY |
24 | # include <sys/time.h> |
25 | #endif |
26 | |
27 | #ifdef _WIN32 |
28 | # ifndef NOMINMAX |
29 | # define NOMINMAX |
30 | # endif |
31 | # include <windows.h> |
32 | #endif |
33 | |
34 | //------------------------------------------------------------------------ |
35 | // GooTimer |
36 | //------------------------------------------------------------------------ |
37 | |
38 | class POPPLER_PRIVATE_EXPORT GooTimer |
39 | { |
40 | public: |
41 | // Create a new timer. |
42 | GooTimer(); |
43 | |
44 | void start(); |
45 | void stop(); |
46 | double getElapsed(); |
47 | |
48 | private: |
49 | #ifdef HAVE_GETTIMEOFDAY |
50 | struct timeval start_time; |
51 | struct timeval end_time; |
52 | #elif defined(_WIN32) |
53 | LARGE_INTEGER start_time; |
54 | LARGE_INTEGER end_time; |
55 | #endif |
56 | bool active; |
57 | }; |
58 | |
59 | #endif |
60 | |