示例#1
0
        private static void KissSpeedTest(int bufferSize)
        {
            var cfg = KissFFT.Alloc(bufferSize, 0);

            var input  = MakeData(bufferSize);
            var output = new Single.Complex[bufferSize];

            double sum   = 0;
            long   count = 0;
            var    start = DateTime.Now;

            while ((DateTime.Now - start).TotalMilliseconds < 1000)
            {
                KissFFT.FFT(cfg, input, output);
                sum += output[0].Real;
                count++;
            }
            sum = sum / count;
            Console.WriteLine("KISS; FFT; {0}; {1}; {2}", bufferSize, count, sum);

            cfg = KissFFT.Alloc(bufferSize, 1);

            sum   = 0;
            count = 0;
            start = DateTime.Now;
            while ((DateTime.Now - start).TotalMilliseconds < 1000)
            {
                KissFFT.FFT(cfg, output, input);
                sum += input[0].Real;
                count++;
            }
            sum = sum / count;
            Console.WriteLine("KISS; IFFT; {0}; {1}; {2}", bufferSize, count, sum);
        }
示例#2
0
        static void TransformNativeSpeedTest(int bufferSize)
        {
            var input  = MakeData(bufferSize);
            var output = new Single.Complex[bufferSize];
            var fft    = new Single.TransformNative(bufferSize);

            double sum   = 0;
            long   count = 0;
            var    start = DateTime.Now;

            while ((DateTime.Now - start).TotalMilliseconds < 1000)
            {
                fft.FFT(input, output);
                sum += output[0].Real;
                count++;
            }
            sum = sum / count;
            Console.WriteLine("Native; FFT; {0}; {1}; {2}", bufferSize, count, sum);

            sum   = 0;
            count = 0;
            start = DateTime.Now;
            while ((DateTime.Now - start).TotalMilliseconds < 1000)
            {
                fft.IFFT(output, input);
                sum += input[0].Real;
                count++;
            }
            sum = sum / count;
            Console.WriteLine("Native; IFFT; {0}; {1}; {2}", bufferSize, count, sum);
        }
示例#3
0
        static Single.Complex[] MakeData(int bufferSize)
        {
            var arr = new Single.Complex[bufferSize];

            for (int j = 0; j < bufferSize; j++)
            {
                arr[j].Real = j / (float)bufferSize;
            }
            return(arr);
        }