Skip to content

Commit

Permalink
Merge branch 'main' into options
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnatsel committed Feb 2, 2024
2 parents 93b9d03 + 7a77829 commit e9dc44f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions benches/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ CC = gcc
CFLAGS = -Wall -Wextra -O3 -march=native
LIBS = -lfftw3 -lm

program: main.c
bench_fftw: main.c
$(CC) $(CFLAGS) -o bench_fftw main.c $(LIBS)

clean:
rm -f program
rm -f bench_fftw

18 changes: 15 additions & 3 deletions benches/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ iters=$3
OUTPUT_DIR=benchmark-data.$(date +"%Y.%m.%d.%H-%M-%S")
mkdir -p "$OUTPUT_DIR"/fftw3 && mkdir "$OUTPUT_DIR"/rustfft && mkdir "$OUTPUT_DIR"/phastft

benchmark_fftw3() {
make clean && make

for n in $(seq "$start" "$end"); do
echo "Running FFTW3 benchmark for N = 2^${n}..." && \
for _ in $(seq 1 "$iters"); do
./bench_fftw "${n}" >> "${OUTPUT_DIR}"/fftw3/size_"${n}"
done
done
}

benchmark_phastft() {
cargo clean && cargo build --release --examples

for n in $(seq "$start" "$end"); do
echo "running PhastFT benchmark for N = 2^${n}" && \
echo "Running PhastFT benchmark for N = 2^${n}..." && \
for _ in $(seq 1 "$iters"); do
../target/release/examples/benchmark "${n}" >> "${OUTPUT_DIR}"/phastft/size_"${n}"
done
Expand All @@ -30,12 +41,13 @@ benchmark_rustfft() {
cargo clean && cargo build --release --examples

for n in $(seq "$start" "$end"); do
echo "running RustFFT benchmark for N = 2^${n}" && \
echo "Running RustFFT benchmark for N = 2^${n}..." && \
for _ in $(seq 1 "$iters"); do
../target/release/examples/rustfft "${n}" >> "${OUTPUT_DIR}"/rustfft/size_"${n}"
done
done
}

benchmark_fftw3
benchmark_phastft
benchmark_rustfft
benchmark_phastft
2 changes: 1 addition & 1 deletion benches/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ int main(int argc, char** argv) {
fftw_plan p = fftw_plan_dft_1d(N, in, in, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(p);
double toc = clock();

double elapsed = ((double)(toc - tic) / CLOCKS_PER_SEC) * 1000000;

printf("%f\n", elapsed);
fftw_free(in);
fftw_destroy_plan(p);
Expand Down
6 changes: 3 additions & 3 deletions examples/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ fn benchmark_fft(n: usize) {
let mut imags = vec![0.0; big_n];
gen_random_signal(&mut reals, &mut imags);

// let now = std::time::Instant::now();
let now = std::time::Instant::now();
fft_dif(&mut reals, &mut imags);
// let elapsed = now.elapsed().as_micros();
// println!("{elapsed}");
let elapsed = now.elapsed().as_micros();
println!("{elapsed}");
}

fn main() {
Expand Down

0 comments on commit e9dc44f

Please sign in to comment.