package xyz.benw.plugins.fouriermc.DataAnalysis.DataTests;

import xyz.benw.plugins.fouriermc.ClickData;

/**
 * ClicksPerSecond
 *
 * Computes a player's clicks per second.
 *
 */
public class ClicksPerSecond implements IDataTest {

    private ClickData data;

    private double result;
    private Long samplePeriod;


    public ClicksPerSecond(ClickData data, Long samplePeriod) {
        this.data = data;
        this.samplePeriod = samplePeriod;
    }

    @Override
    public boolean evaluate() {
        // *20 to convert from ticks to seconds
        result = data.sum() / (samplePeriod*data.size())*20;

        return result < 5;  //TODO: Put test criterias in config
    }

}

@@ -64,44 +64,61 @@
 ort 
-xyz.benw.plugins.fouriermc.ClickData
+org.apache.commons.math3.stat.descriptive.summary.Sum
 ;%0A%0A/
@@ -260,51 +260,23 @@
 ate 
-ClickData data;%0A%0A    private double result;
+double%5B%5D data;%0A
 %0A   
@@ -336,17 +336,16 @@
 ond(
-ClickData
+double%5B%5D
  dat
@@ -489,86 +489,334 @@
 ate(
-) %7B%0A        // *20 to convert from ticks to seconds%0A        result = data.sum(
+double criteria) %7B%0A        return getClicksPerSecond() %3C criteria;%0A    %7D%0A%0A    public double getClicksPerSecond() %7B%0A        double clicksPerSecond;%0A        // *20 to convert from ticks to seconds%0A        int size = data.length;%0A        if(samplePeriod != 0 && size != 0) %7B%0A            clicksPerSecond = (new Sum().evaluate(data
 ) / 
@@ -832,91 +832,117 @@
 riod
-*data.
+ * 
 size
-(
 ))
-*
+ * 
 20;%0A
-%0A        return result %3C 5;  //TODO: Put test criterias in config
+        %7D else %7B%0A            clicksPerSecond = 0.0;%0A        %7D%0A        return clicksPerSecond;
 %0A   

Clean up CPS test