void printData()
    {
        //The csv file will be named YEAR-MONTH-DAY_HOUR-MINUTE
        string curDateTime = "practice_" + System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm") + ".csv";

        TextWriter write = new StreamWriter(curDateTime);

        write.WriteLine("trial number,time,method,background,skipped?");

        string isSkip;

        for (int i = 0; i < totalTrials + skipCount; i++)
        {
            record r = times.getItem(i);

            if (r.getSkip())
            {
                isSkip = "skipped";
            }
            else
            {
                isSkip = " ";
            }

            string mName = r.getMethodName().Replace("(clone)", "");
            string bName = r.getBackgroundName().Replace("(clone)", "");

            write.WriteLine(r.getNumber() + "," + r.getTime() + "," + mName + "," + bName + ", " + isSkip);
        }

        write.Close();
    }
Esempio n. 2
0
    void printData()
    {
        //The csv file will be named YEAR-MONTH-DAY_HOUR-MINUTE
        string curDateTime = System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm") + ".csv";

        TextWriter write = new StreamWriter(curDateTime);

        write.WriteLine("trial number,time,method,background,skipped?,average,standard deviation");

        record r         = null;
        string mName     = "";
        string bName     = "";
        string isSkip    = "";
        float  curTime   = 0.0f;
        float  curTotal  = 0.0f;
        int    numTrials = 0;

        float[] methodTrials = new float[subTrialCount * numBackgrounds];

        for (int i = 0; i < totalTrials + skipCount; i++)
        {
            r       = times.getItem(i);
            curTime = r.getTime();

            mName = r.getMethodName().Replace("(Clone)", "");
            bName = r.getBackgroundName().Replace("(Clone)", "");

            if (r.getSkip())
            {
                isSkip = "skipped";
            }
            else
            {
                isSkip = " ";
            }

            // If this trial wasn't skipped, add the time to the total and count it as a trial
            if (!r.getSkip())
            {
                methodTrials[numTrials] = curTime;
                curTotal += curTime;
                numTrials++;
            }

            // Write the trial to the file (last two spots are the avg and std dev vals that get printed at the end of each method)
            write.WriteLine(r.getNumber() + "," + r.getTime() + "," + mName + "," + bName + ", " + isSkip, " , , ");

            // If that was the last trial for that method, print out the avg and std. dev and reset counters
            if (numTrials == subTrialCount * numBackgrounds)
            {
                float stdDev         = 0.0f;
                float sumDiffSquared = 0.0f;
                float mean           = curTotal / numTrials;

                for (int j = 0; j < subTrialCount * numBackgrounds; j++)
                {
                    // Get the difference of the current time and the mean and square it.
                    sumDiffSquared += Mathf.Pow((methodTrials[j] - mean), 2);
                }

                //Complete the std dev. calculation with the sum of the squared differences
                stdDev = Mathf.Sqrt(sumDiffSquared / (subTrialCount * numBackgrounds));

                write.WriteLine(" , , , , ," + mean + "," + stdDev);

                // Reset the counters
                curTotal  = 0.0f;
                numTrials = 0;
            }
        }

        write.Close();
    }