<commit_before>import glfw

from .base import BaseTimer


class Timer(BaseTimer):
    """
    Timer based on glfw time.
    This is the default / most basic timer.
    """
    def __init__(self, **kwargs):
        self.start_time = None
        self.stop_time = None
        self.pause_time = None
        self.offset = 0
        super().__init__(**kwargs)

    def start(self):
        """Start the timer"""
        if self.start_time is None:
            self.start_time = glfw.get_time()
        # Play after pause
        else:
            # Add the duration of the paused interval to the total offset
            pause_duration = glfw.get_time() - self.pause_time
            self.offset += pause_duration
            # print("pause duration", pause_duration, "offset", self.offset)
            # Exit the paused state
            self.pause_time = None

    def pause(self):
        """Pause the timer"""
        self.pause_time = glfw.get_time()

    def toggle_pause(self):
        """Toggle pause"""
        if self.pause_time:
            self.start()
        else:
            self.pause()

    def stop(self):
        """Stop the timer"""
        self.stop_time = glfw.get_time()
        return self.stop_time - self.start_time - self.offset

    def get_time(self):
        """Get the current time in seconds"""
        if self.pause_time is not None:
            time = self.pause_time - self.offset - self.start_time
            return time

        time = glfw.get_time()
        return time - self.start_time - self.offset
<commit_msg>demosys.timer.Timer should not be based on glfw time<commit_after>import time

from .base import BaseTimer


class Timer(BaseTimer):
    """
    Timer based on python ``time``.
    This is the default / most basic timer.
    """
    def __init__(self, **kwargs):
        self.start_time = None
        self.stop_time = None
        self.pause_time = None
        self.offset = 0
        super().__init__(**kwargs)

    def start(self):
        """Start the timer"""
        if self.start_time is None:
            self.start_time = time.time()
        # Play after pause
        else:
            # Add the duration of the paused interval to the total offset
            pause_duration = time.time() - self.pause_time
            self.offset += pause_duration
            # print("pause duration", pause_duration, "offset", self.offset)
            # Exit the paused state
            self.pause_time = None

    def pause(self):
        """Pause the timer"""
        self.pause_time = time.time()

    def toggle_pause(self):
        """Toggle pause"""
        if self.pause_time:
            self.start()
        else:
            self.pause()

    def stop(self):
        """Stop the timer"""
        self.stop_time = time.time()
        return self.stop_time - self.start_time - self.offset

    def get_time(self):
        """Get the current time in seconds"""
        if self.pause_time is not None:
            curr_time = self.pause_time - self.offset - self.start_time
            return curr_time

        curr_time = time.time()
        return curr_time - self.start_time - self.offset

{'fraction_non_alphanumeric': 0.10034931724356938, 'fraction_numerical': 0.0006351222610352493, 'mean_word_length': 1.8793418647166362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6777151', 'n_tokens_mistral': 894, 'n_tokens_neox': 873, 'n_words': 259}