mirror of
				https://github.com/mborgerding/kissfft.git
				synced 2025-11-04 01:05:19 -05:00 
			
		
		
		
	benchmark utilities now give memory info
This commit is contained in:
		@ -23,15 +23,15 @@ CFLAGS=-Wall -O3 -ansi -pedantic
 | 
			
		||||
$(UTIL): ../kiss_fft.c fftutil.c 
 | 
			
		||||
	gcc -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) ../kiss_fft.c fftutil.c -lm
 | 
			
		||||
 | 
			
		||||
$(BENCH): benchkiss.c ../kiss_fft.c
 | 
			
		||||
	gcc -o $@ $(CFLAGS) -I.. benchkiss.c $(TYPEFLAGS) ../kiss_fft.c -lm 
 | 
			
		||||
$(BENCH): benchkiss.c ../kiss_fft.c pstats.c
 | 
			
		||||
	gcc -o $@ $(CFLAGS) -I.. benchkiss.c $(TYPEFLAGS) ../kiss_fft.c pstats.c -lm 
 | 
			
		||||
 | 
			
		||||
fftw: bm_fftw
 | 
			
		||||
	@[ -x ./bm_fftw ] && \
 | 
			
		||||
		./bm_fftw -x $(NUMFFTS) -n $(NFFT)
 | 
			
		||||
 | 
			
		||||
bm_fftw: benchfftw.c
 | 
			
		||||
	@gcc -o $@ $(CFLAGS) benchfftw.c -lm -lfftw3 -L /usr/local/lib/ \
 | 
			
		||||
bm_fftw: benchfftw.c pstats.c
 | 
			
		||||
	@gcc -o $@ $(CFLAGS) benchfftw.c pstats.c -lm -lfftw3 -L /usr/local/lib/ \
 | 
			
		||||
	 || echo 'Cannot build FFTW test script'
 | 
			
		||||
 | 
			
		||||
time: all
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,7 @@
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <fftw3.h>
 | 
			
		||||
#include <getopt.h>
 | 
			
		||||
#include <sys/times.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include "pstats.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc,char ** argv)
 | 
			
		||||
{
 | 
			
		||||
@ -14,8 +13,8 @@ int main(int argc,char ** argv)
 | 
			
		||||
    fftw_complex * in=NULL;
 | 
			
		||||
    fftw_complex * out=NULL;
 | 
			
		||||
    fftw_plan p;
 | 
			
		||||
    struct tms t0,t1;
 | 
			
		||||
    float cputime;
 | 
			
		||||
 | 
			
		||||
    pstats_init();
 | 
			
		||||
 | 
			
		||||
    while (1) {
 | 
			
		||||
      int c = getopt (argc, argv, "n:ix:");
 | 
			
		||||
@ -41,7 +40,6 @@ int main(int argc,char ** argv)
 | 
			
		||||
        in[i][1] = rand() - RAND_MAX/2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    times(&t0);
 | 
			
		||||
    if ( isinverse )
 | 
			
		||||
        p = fftw_plan_dft_1d(nfft, in, out, FFTW_BACKWARD, FFTW_ESTIMATE);
 | 
			
		||||
    else    
 | 
			
		||||
@ -51,20 +49,12 @@ int main(int argc,char ** argv)
 | 
			
		||||
        fftw_execute(p);
 | 
			
		||||
 | 
			
		||||
    fftw_destroy_plan(p);
 | 
			
		||||
    times(&t1);
 | 
			
		||||
 | 
			
		||||
    fftw_free(in); fftw_free(out);
 | 
			
		||||
 | 
			
		||||
    cputime = ( ((float)t1.tms_utime + t1.tms_stime + t1.tms_cutime + t1.tms_cstime ) - 
 | 
			
		||||
                ((float)t0.tms_utime + t0.tms_stime + t0.tms_cutime + t0.tms_cstime ) )
 | 
			
		||||
             / sysconf(_SC_CLK_TCK);
 | 
			
		||||
    fprintf(stderr,"fftw\tnfft=%d\tnumffts=%d\n", nfft,numffts);
 | 
			
		||||
    pstats_report();
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr,"fftw\t" 
 | 
			
		||||
            "nfft=%d\t"
 | 
			
		||||
            "numffts=%d\t"
 | 
			
		||||
            "cputime=%.3f\n" , 
 | 
			
		||||
            nfft,numffts,cputime
 | 
			
		||||
            );
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,13 +5,13 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include "kiss_fft.h"
 | 
			
		||||
 | 
			
		||||
#include "pstats.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc,char ** argv)
 | 
			
		||||
{
 | 
			
		||||
    int nfft=1024;
 | 
			
		||||
    int isinverse=0;
 | 
			
		||||
    int numffts=1000,i;
 | 
			
		||||
    struct tms t0,t1;
 | 
			
		||||
    float cputime;
 | 
			
		||||
    kiss_fft_cpx * buf;
 | 
			
		||||
    kiss_fft_cpx * bufout;
 | 
			
		||||
    void *st;
 | 
			
		||||
@ -40,27 +40,20 @@ int main(int argc,char ** argv)
 | 
			
		||||
        buf[i].i = rand() - RAND_MAX/2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    times(&t0);
 | 
			
		||||
    pstats_init();
 | 
			
		||||
 | 
			
		||||
    st = kiss_fft_alloc( nfft ,isinverse );
 | 
			
		||||
 | 
			
		||||
    for (i=0;i<numffts;++i)
 | 
			
		||||
        kiss_fft_io( st ,buf,bufout );
 | 
			
		||||
 | 
			
		||||
    free(st);
 | 
			
		||||
    times(&t1);
 | 
			
		||||
 | 
			
		||||
    free(buf); free(bufout);
 | 
			
		||||
 | 
			
		||||
    cputime = ( ((float)t1.tms_utime + t1.tms_stime + t1.tms_cutime + t1.tms_cstime ) - 
 | 
			
		||||
                ((float)t0.tms_utime + t0.tms_stime + t0.tms_cutime + t0.tms_cstime ) )
 | 
			
		||||
             / sysconf(_SC_CLK_TCK);
 | 
			
		||||
    fprintf(stderr,"KISS\tnfft=%d\tnumffts=%d\n" ,nfft,numffts);
 | 
			
		||||
    pstats_report();
 | 
			
		||||
 | 
			
		||||
    fprintf(stderr,"KISS\t" 
 | 
			
		||||
            "nfft=%d\t"
 | 
			
		||||
            "numffts=%d\t"
 | 
			
		||||
            "cputime=%.3f\n" , 
 | 
			
		||||
            nfft,numffts,cputime
 | 
			
		||||
            );
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										41
									
								
								test/pstats.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								test/pstats.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <sys/times.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
static struct tms tms_beg;
 | 
			
		||||
static struct tms tms_end;
 | 
			
		||||
static int has_times = 0;
 | 
			
		||||
 | 
			
		||||
void pstats_init()
 | 
			
		||||
{
 | 
			
		||||
    has_times = times(&tms_beg) != -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void tms_report()
 | 
			
		||||
{
 | 
			
		||||
    double cputime;
 | 
			
		||||
    if (! has_times )
 | 
			
		||||
        return;
 | 
			
		||||
    times(&tms_end);
 | 
			
		||||
    cputime = ( ((float)tms_end.tms_utime + tms_end.tms_stime + tms_end.tms_cutime + tms_end.tms_cstime ) -
 | 
			
		||||
                ((float)tms_beg.tms_utime + tms_beg.tms_stime + tms_beg.tms_cutime + tms_beg.tms_cstime ) )
 | 
			
		||||
               / sysconf(_SC_CLK_TCK);
 | 
			
		||||
    fprintf(stderr,"\tcputime=%.3f\n" , cputime);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ps_report()
 | 
			
		||||
{
 | 
			
		||||
    char buf[1024];
 | 
			
		||||
    sprintf(buf,"ps -o comm,majflt,minflt,rss,drs,pagein,sz,trs,vsz %d 1>&2",getpid() );
 | 
			
		||||
    system( buf );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pstats_report()
 | 
			
		||||
{
 | 
			
		||||
    ps_report();
 | 
			
		||||
    tms_report();
 | 
			
		||||
    fprintf(stderr,"\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								test/pstats.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								test/pstats.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#ifndef PSTATS_H
 | 
			
		||||
#define PSTATS_H
 | 
			
		||||
 | 
			
		||||
void pstats_init();
 | 
			
		||||
void pstats_report();
 | 
			
		||||
 
 | 
			
		||||
#endif
 | 
			
		||||
@ -23,15 +23,15 @@ CFLAGS=-Wall -O3 -ansi -pedantic
 | 
			
		||||
$(UTIL): ../kiss_fft.c fftutil.c 
 | 
			
		||||
	gcc -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) ../kiss_fft.c fftutil.c -lm
 | 
			
		||||
 | 
			
		||||
$(BENCH): benchkiss.c ../kiss_fft.c
 | 
			
		||||
	gcc -o $@ $(CFLAGS) -I.. benchkiss.c $(TYPEFLAGS) ../kiss_fft.c -lm 
 | 
			
		||||
$(BENCH): benchkiss.c ../kiss_fft.c pstats.c
 | 
			
		||||
	gcc -o $@ $(CFLAGS) -I.. benchkiss.c $(TYPEFLAGS) ../kiss_fft.c pstats.c -lm 
 | 
			
		||||
 | 
			
		||||
fftw: bm_fftw
 | 
			
		||||
	@[ -x ./bm_fftw ] && \
 | 
			
		||||
		./bm_fftw -x $(NUMFFTS) -n $(NFFT)
 | 
			
		||||
 | 
			
		||||
bm_fftw: benchfftw.c
 | 
			
		||||
	@gcc -o $@ $(CFLAGS) benchfftw.c -lm -lfftw3 -L /usr/local/lib/ \
 | 
			
		||||
bm_fftw: benchfftw.c pstats.c
 | 
			
		||||
	@gcc -o $@ $(CFLAGS) benchfftw.c pstats.c -lm -lfftw3 -L /usr/local/lib/ \
 | 
			
		||||
	 || echo 'Cannot build FFTW test script'
 | 
			
		||||
 | 
			
		||||
time: all
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user