+/GENN

genetically evolving neural networks

git clone https://git.julia.blue/+/GENN

Joseph RyanAdd benchmark code for python and c++544bdde

v0.1
1.2 KiB46 linesraw
1#ifdef _WIN32
2#include <Windows.h>
3#else
4#include <sys/time.h>
5#include <ctime>
6#endif
7
8/* Remove if already defined */
9typedef long long int64; typedef unsigned long long uint64;
10
11/* Returns the amount of milliseconds elapsed since the UNIX epoch. Works on both
12 * windows and linux. */
13
14uint64 GetTimeMs64(){
15#ifdef _WIN32
16        /* Windows */
17        FILETIME ft;
18        LARGE_INTEGER li;
19
20        /* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and copy it
21         * to a LARGE_INTEGER structure. */
22        GetSystemTimeAsFileTime(&ft);
23        li.LowPart = ft.dwLowDateTime;
24        li.HighPart = ft.dwHighDateTime;
25
26        uint64 ret = li.QuadPart;
27        ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */
28        ret /= 10000; /* From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals */
29
30        return ret;
31#else
32        /* Linux */
33        struct timeval tv;
34
35        gettimeofday(&tv, NULL);
36
37        uint64 ret = tv.tv_usec;
38        /* Convert from micro seconds (10^-6) to milliseconds (10^-3) */
39        ret /= 1000;
40
41        /* Adds the seconds (10^0) after converting them to milliseconds (10^-3) */
42        ret += (tv.tv_sec * 1000);
43
44        return ret;
45#endif
46}