<commit_before>package net.slreynolds.ds;

/**
 * Base class for timing tests.
 *
 * @param <S> Type parameter of Result that has memory reference accumulated during
 * doWork
 * @param <T> Type of object returned from setUp and passed as an argument to doWork
 */
public abstract class AbstractTiming<S,T> {
    
    protected abstract T setUp();

    protected abstract Result<S> doWork(T o);
    
    private int warmUp(int N) {
        T o;
        int computation = 7;
        for (int i = 0; i < N; i++) {
            o = setUp();
            Result<S> res = doWork(o); 
            computation |= res.getIntParam();
        }
        return computation;
    }
    
    private long measureSpace() {
        
        int computation = 7;
        T o = setUp();
        Runtime runt = Runtime.getRuntime();
        
        System.gc();
        System.gc();
        System.gc();
        System.gc();
        System.gc();
        long before = runt.totalMemory();
        
        Result<S> res = doWork(o);
       
        System.gc();
        System.gc();
        System.gc();
        System.gc();
        System.gc();
        long after = runt.totalMemory();

        computation |= res.getIntParam();
            
        System.out.printf("%d\n", computation);
        return Math.max(0,(after - before)); <commit_msg>Improved structure of space computation. Sleep a bit to allow gc to run.<commit_after>package net.slreynolds.ds;

/**
 * Base class for timing tests.
 *
 * @param <S> Type parameter of Result that has memory reference accumulated during
 * doWork
 * @param <T> Type of object returned from setUp and passed as an argument to doWork
 */
public abstract class AbstractTiming<S,T> {
    
    protected abstract T setUp();

    protected abstract Result<S> doWork(T o);
    
    private int warmUp(int N) {
        T o;
        int computation = 7;
        for (int i = 0; i < N; i++) {
            o = setUp();
            Result<S> res = doWork(o); 
            computation |= res.getIntParam();
        }
        return computation;
    }
    
    private void sleep() {
        try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// don't care
		}
    }
    
    private long getMemoryUsed() {
        Runtime runt = Runtime.getRuntime();
        System.gc();
        System.gc();
        System.gc();
        sleep();
        System.gc();
        System.gc();
        sleep();
        return runt.totalMemory();
    }
    
    private long measureSpace() {
        
        int computation = 7;
        T o = setUp();
        long before = getMemoryUsed();
        
        Result<S> res = doWork(o);
        long after = getMemoryUsed();

        computation |= res.getIntParam();
            
        System.out.printf("%d\n", computation);
        return Math.max(0,(after - before)); 
{'fraction_non_alphanumeric': 0.11895517119661136, 'fraction_numerical': 0.004235792446170138, 'mean_word_length': 1.800395256916996, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '1447205', 'n_tokens_mistral': 821, 'n_tokens_neox': 804, 'n_words': 246}