<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fi.lolcatz.profiler;

import java.lang.Math.*;

public class TestingFramework {

    Output<?> out;

    public TestingFramework(){        
    }
    
    public TestingFramework(Output<?> out) {
        this.out = out;
    }
    
    /*
     * Calculates the linearity of the class variable out
     */  
    public boolean isLinear(){
        if (out.getSize().size() < 2) return false;
        Integer x0 = out.getSize().get(0);
        Long y0 = out.getTime().get(0);    
        Integer xn = out.getSize().get(out.getSize().size()-1);
        Long yn = out.getTime().get(out.getTime().size()-1);
        double a = Math.abs(y0-yn)/Math.abs(x0-xn);
        double b = y0 - a*x0;     
        for (int i = 0; i < out.getTime().size(); i++){          
            double time = out.getTime().get(i);
            double function = a*out.getSize().get(i)+b;   
            boolean linearity = time*1.05 >= function ? true : false;
            if (!linearity) return false;
        }
        return true;
    }
    
    /*
     * Calculates the linearity of the parameter variable out
     */  
    public boolean isLinear(Output<?> output){
        if (output.getSize().size() < 2) return false;
        Integer x0 = output.getSize().get(0);
        Long y0 = output.getTime().get(0);    
        Integer xn = output.getSize().get(output.getSize().size()-1);
        Long yn = output.getTime().get(output.getTime().size()-1);
        double a = Math.abs(y0-yn)/Math.abs(x0-xn);
        double b = y0 - a*x0;     
        for (int i = 0; i < output.getTime().size(); i++){          
            double time = output.getTime().get(i);
            double function = a*output.getSize().get(i)+b;   
            boolean linearity = time*1.05 >= function ? true : false;
            if (!linearity) return false;
        }
        return true;
    }
    
    public boolean isExponential(long[][] array){
        return true;
    }
    
    <commit_msg>Added approximation<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fi.lolcatz.profiler;

import java.lang.Math.*;

public class TestingFramework {

    Output<?> out;

    public TestingFramework(){        
    }
    
    public TestingFramework(Output<?> out) {
        this.out = out;
    }
    
    /*
     * Calculates the linearity of the class variable out
     */  
    public boolean isLinear(){
        if (out.getSize().size() < 2) return false;
        Integer x0 = out.getSize().get(0);
        Long y0 = out.getTime().get(0);    
        Integer xn = out.getSize().get(out.getSize().size()-1);
        Long yn = out.getTime().get(out.getTime().size()-1);
        double a = Math.abs(y0-yn)/Math.abs(x0-xn);
        double b = y0 - a*x0;     
        for (int i = 0; i < out.getTime().size(); i++){          
            double time = out.getTime().get(i);
            double function = a*out.getSize().get(i)+b;   
            System.out.println("Time: " + time);
            System.out.println("Function: " + function);
            boolean linearity = (time*1.002 >= function && time-(time*0.002) <= function) ? true : false;
            if (!linearity) return false;
        }
        return true;
    }
    
    /*
     * Calculates the linearity of the parameter variable out
     */  
    public boolean isLinear(Output<?> output){
        if (output.getSize().size() < 2) return false;
        Integer x0 = output.getSize().get(0);
        Long y0 = output.getTime().get(0);    
        Integer xn = output.getSize().get(output.getSize().size()-1);
        Long yn = output.getTime().get(output.getTime().size()-1);
        double a = Math.abs(y0-yn)/Math.abs(x0-xn);
        double b = y0 - a*x0;     
        for (int i = 0; i < output.getTime().size(); i++){          
            double time = output.getTime().get(i);
            double function = a*output.getSize().get(i)+b;   
            boolean linearity = time*1.05 >= function ? true : false;
            if (!linearity) return false;
        }
        return true;
    }
    
    public boolean isExponential(long[][] array){
        return true;
    }
    
    
{'fraction_non_alphanumeric': 0.1490205223880597, 'fraction_numerical': 0.01515858208955224, 'mean_word_length': 1.901894451962111, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 13, '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': '7150076', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1326, 'n_words': 323}