/* -*- mode: C++; indent-tabs-mode: nil; -*-
* This file is a part of LEMON, a generic C++ optimization library.
* Copyright (C) 2003-2009
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
///\brief Some basic non-inline functions and static global data.
#include<lemon/bits/windows.h>
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
void getWinProcTimes(double &rtime,
double &utime, double &stime,
double &cutime, double &cstime)
static const double ch = 4294967296.0e-7;
static const double cl = 1.0e-7;
GetSystemTimeAsFileTime(&system);
rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
FILETIME create, exit, kernel, user;
if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
double tck=sysconf(_SC_CLK_TCK);
cutime=ts.tms_cutime/tck;
cstime=ts.tms_cstime/tck;
std::string getWinFormattedDate()
#if defined(_MSC_VER) && (_MSC_VER < 1500)
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
L"ddd MMM dd", buf1, 11) &&
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
L"HH':'mm':'ss", buf2, 9) &&
GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
os << buf1 << ' ' << buf2 << ' ' << buf3;
char buf1[11], buf2[9], buf3[5];
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
"ddd MMM dd", buf1, 11) &&
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
"HH':'mm':'ss", buf2, 9) &&
GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
os << buf1 << ' ' << buf2 << ' ' << buf3;
ctime_r(&tv.tv_sec,cbuf);
GetSystemTimeAsFileTime(&time);
return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime;
return getpid() + tv.tv_sec + tv.tv_usec;