Exemplo n.º 1
0
        private static long speedTest(SinCosTable table, int numIterations, int numTrials)
        {
            long startTime, endTime;
            long totalTime = 0;
            float i, j;
            float k = 0;

            float jstep = MathUtils.TWOPI/numIterations;

            for (i = 0; i < numTrials; i++)
            {

                startTime = Stopwatch.GetTimestamp();
                for (j = 0; j < MathUtils.TWOPI; j += jstep)
                {
                    k += table.sin(j);
                }
                endTime = Stopwatch.GetTimestamp();
                totalTime += endTime - startTime;
            }
            i += k;

            return numIterations*numTrials*1000000000L/(totalTime);
        }
Exemplo n.º 2
0
        private static double accuracyTest(SinCosTable table, int iterations)
        {
            double totalDiff = 0f, diff = 0f;

            for (int i = 0; i < iterations; i++)
            {
                float querry = (float) _random.NextDouble()*MathUtils.TWOPI;
                diff = MathUtils.abs((float) System.Math.Sin(querry) - table.sin(querry));
                totalDiff += diff;
            }
            totalDiff /= iterations;
            return totalDiff;
        }