<commit_before><?php

namespace Neutron\TipTop;

class Clock
{
    private $stack = array();

    public function __construct()
    {
        $this->initialize();
        $this->set(1, function(){echo memory_get_usage()."\n";});
    }

    private function initialize()
    {
        declare(ticks = 1);
        pcntl_signal(SIGALRM, array($this, 'beat'), true);
        pcntl_alarm((int) 1);
    }

    public function beat()
    {
        $toReset = $toRemove = array();

        foreach ($this->stack as $moment => $timers) {
            if ($moment > time()) {
                break;
            }

            foreach ($timers as $timer) {
                call_user_func($timer->callback);
                $timer->iterations--;

                if ($timer->iterations > 0) {
                    if(!isset($toReset[$moment + $timer->period])) {
                        $toReset[$moment + $timer->period] = array();
                    }
                    array_push($toReset[$moment + $timer->period],$timer);
                }
                $toRemove[] = $moment;
            }
        }

        foreach ($toRemove as $moment) {
            unset($this->stack[$moment]);
        }

        $sort = false;

        foreach ($toReset as $moment => $timers) {
            if (!isset($this->stack[$moment])) {
                $this->stack[$moment] = array();
                $sort = true;
            }
            $this->stack[$moment] = array_merge($this->stack[$moment], $timers);
        }

        if ($sort === true) {
            ksort($this->stack);
        }

        pcntl_alarm(1);
    }

    public function set($seconds, $callback, $iterations = INF)
    {
        $moment = time() + $seconds;

        if (!isset($this->stack[$moment])) {
            $this->stack[$moment] = array();
            ksort($this->stack);
        }

        $data = (object) array(
                'period'     => $seconds,
                'callback'   => $callback,
                'iterations' => $iterations,
        );

        array_push($this->stack[$moment], $data);
    }

    public function clear()
    {
        $this->stack = array();
    }
}
<commit_msg>Remove memory display<commit_after><?php

namespace Neutron\TipTop;

class Clock
{
    private $stack = array();

    public function __construct()
    {
        $this->initialize();
    }

    private function initialize()
    {
        declare(ticks = 1);
        pcntl_signal(SIGALRM, array($this, 'beat'), true);
        pcntl_alarm((int) 1);
    }

    public function beat()
    {
        $toReset = $toRemove = array();

        foreach ($this->stack as $moment => $timers) {
            if ($moment > time()) {
                break;
            }

            foreach ($timers as $timer) {
                call_user_func($timer->callback);
                $timer->iterations--;

                if ($timer->iterations > 0) {
                    if(!isset($toReset[$moment + $timer->period])) {
                        $toReset[$moment + $timer->period] = array();
                    }
                    array_push($toReset[$moment + $timer->period],$timer);
                }
                $toRemove[] = $moment;
            }
        }

        foreach ($toRemove as $moment) {
            unset($this->stack[$moment]);
        }

        $sort = false;

        foreach ($toReset as $moment => $timers) {
            if (!isset($this->stack[$moment])) {
                $this->stack[$moment] = array();
                $sort = true;
            }
            $this->stack[$moment] = array_merge($this->stack[$moment], $timers);
        }

        if ($sort === true) {
            ksort($this->stack);
        }

        pcntl_alarm(1);
    }

    public function set($seconds, $callback, $iterations = INF)
    {
        $moment = time() + $seconds;

        if (!isset($this->stack[$moment])) {
            $this->stack[$moment] = array();
            ksort($this->stack);
        }

        $data = (object) array(
                'period'     => $seconds,
                'callback'   => $callback,
                'iterations' => $iterations,
        );

        array_push($this->stack[$moment], $data);
    }

    public function clear()
    {
        $this->stack = array();
    }
}

{'fraction_non_alphanumeric': 0.1596441947565543, 'fraction_numerical': 0.002106741573033708, 'mean_word_length': 1.4886429819452534, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '3802234', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1179, 'n_words': 229}