<commit_before>/*
 * jPOS Project [http://jpos.org]
 * Copyright (C) 2000-2012 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.jpos.util;

import java.io.PrintStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;

/**
 * Simple Profiler
 * @author <NAME>
 * @author <NAME>
 * @version $Id$
 */
public class Profiler implements Loggeable {
    long start, partial;
    LinkedHashMap events;
    public static final int TO_MILLIS = 1000000;

    public Profiler () {
        super();
        reset();
    }
    /**
     * reset timers
     */
    public void reset() {
        start = partial = System.nanoTime();
        events = new LinkedHashMap();
    }
    /**
     * mark checkpoint
     * @param detail checkpoint information
     */
    @SuppressWarnings("unchecked")
    public synchronized void checkPoint (String detail) {
        long now = System.nanoTime();
        Entry e = new Entry();
        e.setDurationInNanos((now - partial));
        e.setTotalDurationInNanos((now - start));
        if (events.containsKey(detail)) {
            for (int i=1; ;i++) {
                String d = detail + "-" + i;
                if (!events.containsKey (d)) {
                    detail = d;
                    break;
                }
            }
        }
        e.setEventName(detail);
        events.put (detail, e);
        partial = now;
    }
    /**
     * @return total elapsed time since last reset
     */
    public long getElapsed() {
        return System.nanoTime() - start;
    }
    /**
     * @return parcial elapsed time since last reset
     */
    public long getPartial() {
        return System.nanoTime() - partial;
    }
    public void dump (PrintStream p, String indent) {
        String inner = indent + "  ";
        partial = start;
        if (!events.containsKey("end"))
            checkPoint ("end");<commit_msg>End now shows partial time after last checkpoint<commit_after>/*
 * jPOS Project [http://jpos.org]
 * Copyright (C) 2000-2012 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.jpos.util;

import java.io.PrintStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;

/**
 * Simple Profiler
 * @author <NAME>
 * @author <NAME>
 * @version $Id$
 */
public class Profiler implements Loggeable {
    long start, partial;
    LinkedHashMap events;
    public static final int TO_MILLIS = 1000000;

    public Profiler () {
        super();
        reset();
    }
    /**
     * reset timers
     */
    public void reset() {
        start = partial = System.nanoTime();
        events = new LinkedHashMap();
    }
    /**
     * mark checkpoint
     * @param detail checkpoint information
     */
    @SuppressWarnings("unchecked")
    public synchronized void checkPoint (String detail) {
        long now = System.nanoTime();
        Entry e = new Entry();
        e.setDurationInNanos((now - partial));
        e.setTotalDurationInNanos((now - start));
        if (events.containsKey(detail)) {
            for (int i=1; ;i++) {
                String d = detail + "-" + i;
                if (!events.containsKey (d)) {
                    detail = d;
                    break;
                }
            }
        }
        e.setEventName(detail);
        events.put (detail, e);
        partial = now;
    }
    /**
     * @return total elapsed time since last reset
     */
    public long getElapsed() {
        return System.nanoTime() - start;
    }
    /**
     * @return parcial elapsed time since last reset
     */
    public long getPartial() {
        return System.nanoTime() - partial;
    }
    public void dump (PrintStream p, String indent) {
        String inner = indent + "  ";
        if (!events.containsKey("end"))
            checkPoint ("end");
{'fraction_non_alphanumeric': 0.10396233817183209, 'fraction_numerical': 0.006669282071400549, 'mean_word_length': 2.2251739405439594, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1451841', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1379, 'n_words': 498}