SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SysUtils.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 //
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
29 #include "SysUtils.h"
30 
31 #ifndef WIN32
32 #include <sys/time.h>
33 #else
34 #include <windows.h>
35 #endif
36 
37 #ifdef CHECK_MEMORY_LEAKS
38 #include <foreign/nvwa/debug_new.h>
39 #endif // CHECK_MEMORY_LEAKS
40 
41 
42 // ===========================================================================
43 // member method definitions
44 // ===========================================================================
45 long
47 #ifndef WIN32
48  timeval current;
49  gettimeofday(&current, 0);
50  long nanosecs =
51  (long) current.tv_sec * 1000L + (long) current.tv_usec / 1000L;
52  return nanosecs;
53 #else
54  LARGE_INTEGER val, val2;
55  BOOL check = QueryPerformanceCounter(&val);
56  check = QueryPerformanceFrequency(&val2);
57  return (long)(val.QuadPart * 1000 / val2.QuadPart);
58 #endif
59 }
60 
61 
62 
63 /****************************************************************************/
64