Skip to content

Commit

Permalink
CVS style bench output #7
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Jun 19, 2023
1 parent d5a71ec commit 82887e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
9 changes: 4 additions & 5 deletions cpp/examples/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

int main()
{
std::cout << "CPP;\tQDFT;\tIQDFT" << std::endl;

const auto samplerate = 44100;
const auto bandwidth = std::make_pair(50.0, samplerate / 2.0);
const auto resolution = 24;
Expand All @@ -19,7 +21,7 @@ int main()
const auto tb0 = std::chrono::high_resolution_clock::now();
const auto e0 = std::chrono::duration_cast<std::chrono::microseconds>(tb0 - ta0).count();

std::cout << "PREP\t" << "CPP\t" << e0 << " us" << std::endl;
std::cout << "0" << ";\t" << e0 << ";\t" << e0 << std::endl;

const auto n = 1 * samplerate;
const auto m = qdft.size();
Expand All @@ -31,8 +33,6 @@ int main()

for (auto run = 1; run <= runs; ++run)
{
std::cout << "RUN\t" << run << "/" << runs << std::endl;

std::fill(x.begin(), x.end(), 0.0);
std::fill(y.begin(), y.end(), 0.0);

Expand All @@ -46,8 +46,7 @@ int main()
const auto tb2 = std::chrono::high_resolution_clock::now();
const auto e2 = std::chrono::duration_cast<std::chrono::microseconds>(tb2 - ta2).count();

std::cout << "\tQDFT\t" << e1 << " us" << std::endl;
std::cout << "\tIQDFT\t" << e2 << " us" << std::endl;
std::cout << run << ";\t" << e1 << ";\t" << e2 << std::endl;
}

return 0;
Expand Down
9 changes: 4 additions & 5 deletions python/examples/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from timeit import default_timer as timer
import numpy as np

print("PYTHON;\tQDFT;\tIQDFT")

samplerate = 44100
bandwidth = (50, samplerate / 2)
resolution = 24
Expand All @@ -17,7 +19,7 @@
tb0 = timer()
e0 = int((tb0 - ta0) * 1e+6)

print(f"PREP\tPYTHON\t{e0} us")
print(f"0;\t{e0};\t{e0}")

n = 1 * samplerate

Expand All @@ -27,8 +29,6 @@

for run in range(1, runs + 1):

print(f"RUN\t{run}/{runs}")

x[:] = 0

ta1 = timer()
Expand All @@ -41,5 +41,4 @@
tb2 = timer()
e2 = int((tb2 - ta2) * 1e+6)

print(f"\tQDFT\t{e1} us")
print(f"\tIQDFT\t{e2} us")
print(f"{run};\t{e1};\t{e2}")
15 changes: 7 additions & 8 deletions rust/examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use std::time::Instant;
type c64 = num::complex::Complex<f64>;

fn main() {
println!("RUST;\tQDFT;\tIQDFT");

let samplerate = 44100.0;
let bandwidth = (50.0, samplerate / 2.0);
let resolution = 24.0;
Expand All @@ -20,9 +22,9 @@ fn main() {
resolution,
latency,
window);
let e0 = t0.elapsed();
let e0 = t0.elapsed().as_micros();

println!("PREP\tRUST\t{} us", e0.as_micros());
println!("0;\t{e0};\t{e0}");

let n = 1 * samplerate as usize;
let m = qdft.size();
Expand All @@ -33,20 +35,17 @@ fn main() {
let runs = 10;

for run in 1 .. runs + 1 {
println!("RUN\t{}/{}", run, runs);

x.fill(f64::zero());
y.fill(c64::zero());

let t1 = Instant::now();
qdft.qdft(&x, &mut y);
let e1 = t1.elapsed();
let e1 = t1.elapsed().as_micros();

let t2 = Instant::now();
qdft.iqdft(&y, &mut x);
let e2 = t2.elapsed();
let e2 = t2.elapsed().as_micros();

println!("\tQDFT\t{} us", e1.as_micros());
println!("\tIQDFT\t{} us", e2.as_micros());
println!("{run};\t{e1};\t{e2}");
}
}

0 comments on commit 82887e3

Please sign in to comment.