#include "FluidSim/PulseTestScenario.hpp" #include "FluidSim/Scenario.hpp" #include #include #include using namespace fluidsim::port; int main(int argc, char **argv) { // Track the hot-engine cost over time; a one-second benchmark misses it. if (argc > 1 && std::string(argv[1]) == "--soak") { const int seconds = argc > 2 ? std::stoi(argv[2]) : 12; for (float pedal : {0.0f, 1.0f}) { FourStrokeTwinScenario scenario; scenario.throttle = pedal; for (int second = 0; second < seconds; ++second) { const auto before = scenario.snapshot(); const auto start = std::chrono::steady_clock::now(); for (int sample = 0; sample < 44100; ++sample) scenario.process(); const double wall = std::chrono::duration(std::chrono::steady_clock::now() - start).count(); const auto after = scenario.snapshot(); std::cout << "pedal=" << pedal << " second=" << second + 1 << " wall_seconds=" << wall << " rpm=" << after.rpm << " substeps/frame=" << (after.solver_substeps - before.solver_substeps) / 44100.0 << " boundary_iterations/frame=" << (after.boundary_iterations - before.boundary_iterations) / 44100.0 << std::endl; } } return 0; } int samples = argc > 1 ? std::stoi(argv[1]) : 44100; for (int n : {64, 256, 1024}) { Pipe1D p(.001f, 2.f, n); p.damping_multiplier = 0; p.energy_relaxation_rate = 0; double sum = 0; auto t = std::chrono::steady_clock::now(); for (int i = 0; i < samples; i++) { auto l = p.state(0), r = p.state(n - 1); l.velocity = -l.velocity; r.velocity = -r.velocity; p.left_ghost = l; p.right_ghost = r; p.advance(0.0000005f); sum += p.state(n / 2).pressure; } double sec = std::chrono::duration(std::chrono::steady_clock::now() - t).count(); std::cout << "pipe cells=" << n << " steps=" << samples << " seconds=" << sec << " Mcells/s=" << n * double(samples) / sec / 1e6 << " checksum=" << sum << '\n'; } FourStrokeTwinScenario s; s.throttle = .35f; double sum = 0; auto t = std::chrono::steady_clock::now(); for (int i = 0; i < samples; i++) { auto a = s.process(); sum += a.left; } double sec = std::chrono::duration(std::chrono::steady_clock::now() - t).count(); std::cout << "twin seconds=" << sec << " realtime_factor=" << samples / 44100.0 / sec << " checksum=" << sum << '\n'; }