Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows / speeup: load libraries only on startup only #1418

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
port GetTickCount64
  • Loading branch information
giampaolo committed Feb 20, 2019
commit 8e2c4b1644053e4e317a99e6d31070de093e57be
4 changes: 0 additions & 4 deletions psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ psutil_get_num_cpus(int fail_on_err) {
static PyObject *TimeoutExpired;
static PyObject *TimeoutAbandoned;

static ULONGLONG (*psutil_GetTickCount64)(void) = NULL;

/*
* Return a Python float representing the system uptime expressed in seconds
* since the epoch.
Expand All @@ -255,7 +253,6 @@ psutil_boot_time(PyObject *self, PyObject *args) {
time_t pt;
FILETIME fileTime;
long long ll;
psutil_GetTickCount64;

GetSystemTimeAsFileTime(&fileTime);
/*
Expand Down Expand Up @@ -284,7 +281,6 @@ psutil_boot_time(PyObject *self, PyObject *args) {
// "#if (_WIN32_WINNT >= 0x0600)" pre-processor but that way
// the produced exe/wheels cannot be used on Windows XP, see:
// https://github.com/giampaolo/psutil/issues/811#issuecomment-230639178
psutil_GetTickCount64 = psutil_GetProcAddress("kernel32", "GetTickCount64");
if (psutil_GetTickCount64 != NULL) {
// Windows >= Vista
uptime = psutil_GetTickCount64() / (ULONGLONG)1000.00f;
Expand Down
4 changes: 4 additions & 0 deletions psutil/arch/windows/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef PSTR (NTAPI * _RtlIpv4AddressToStringA)(struct in_addr *, PSTR);
typedef PSTR (NTAPI * _RtlIpv6AddressToStringA)(struct in6_addr *, PSTR);
typedef DWORD (_stdcall * NTQSI_PROC) (int, PVOID, ULONG, PULONG);
typedef DWORD (CALLBACK *_GetActiveProcessorCount)(WORD);
typedef ULONGLONG (CALLBACK *_GetTickCount64)(void);


_RtlIpv4AddressToStringA \
Expand All @@ -34,4 +35,7 @@ _GetActiveProcessorCount \
PWINSTATIONQUERYINFORMATIONW \
psutil_WinStationQueryInformationW;

_GetTickCount64 \
psutil_GetTickCount64;

int psutil_load_globals();