<commit_before>import os
from itertools import izip

if os.name == 'nt':
    import win32api
    import win32con
    import win32event
    import win32file
    import win32process

from . import (
    generate_intervals,
    local_stopwatch,
)


def get_elapsed_time(process):
    """Get total processor time consumed by process, in seconds."""
    times = win32process.GetProcessTimes(process)
    return float(times['UserTime']) / 10000000.0 \
        + float(times['KernelTime']) / 10000000.0


def get_memory_usage(process):
    info = win32process.GetProcessMemoryInfo(process)
    unit = 1024.0 * 1024.0 * 1024.0
    return (float(info['PagefileUsage']) / unit,
            float(info['WorkingSetSize']) / unit)


class ProcessMonitor(object):
    def __init__(self, pid=win32process.GetCurrentProcessId()):
        self.pid = pid
        self.process = win32api.OpenProcess(
            win32con.PROCESS_ALL_ACCESS, False, self.pid,
        )

    def __del__(self):
        if self.process:
            win32file.CloseHandle(self.process)
            self.process = None

    def exit_code(self):
        result = win32event.WaitForSingleObject(self.process, 0)
        if result == win32con.WAIT_TIMEOUT:
            return None
        else:
            return win32process.GetExitCodeProcess(self.process)

    def elapsed_time(self):
        return get_elapsed_time(self.process)

    def memory_usage(self):
        return get_memory_usage(self.process)

    # Poll elapsed time at arbitraty frequency (scaling arcordingly),
    # taking into account the number of processors on the system.
    def cpu_usage(self):<commit_msg>Fixes documentation build on Linux.<commit_after>import os
from itertools import izip

if os.name == 'nt':
    import win32api
    import win32con
    import win32event
    import win32file
    import win32process

from . import (
    generate_intervals,
    local_stopwatch,
)


def get_elapsed_time(process):
    """Get total processor time consumed by process, in seconds."""
    times = win32process.GetProcessTimes(process)
    return float(times['UserTime']) / 10000000.0 \
        + float(times['KernelTime']) / 10000000.0


def get_memory_usage(process):
    info = win32process.GetProcessMemoryInfo(process)
    unit = 1024.0 * 1024.0 * 1024.0
    return (float(info['PagefileUsage']) / unit,
            float(info['WorkingSetSize']) / unit)


class ProcessMonitor(object):
    def __init__(self, pid=None):
        if pid is None:
            pid = win32process.GetCurrentProcessId()
        self.pid = pid
        self.process = win32api.OpenProcess(
            win32con.PROCESS_ALL_ACCESS, False, self.pid,
        )

    def __del__(self):
        if self.process:
            win32file.CloseHandle(self.process)
            self.process = None

    def exit_code(self):
        result = win32event.WaitForSingleObject(self.process, 0)
        if result == win32con.WAIT_TIMEOUT:
            return None
        else:
            return win32process.GetExitCodeProcess(self.process)

    def elapsed_time(self):
        return get_elapsed_time(self.process)

    def memory_usage(self):
        return get_memory_usage(self.process)

    # Poll elapsed time at arbitraty frequency (scaling arcordingly),
    # taking into account the number of processors on the system.
    def cpu_usage(self):
{'fraction_non_alphanumeric': 0.0904747685876381, 'fraction_numerical': 0.0370259779038519, 'mean_word_length': 2.855005753739931, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1508590', 'n_tokens_mistral': 1076, 'n_tokens_neox': 967, 'n_words': 237}