From bcfb79fb3b3e061a1bad4a17c4edd5c1b110608f Mon Sep 17 00:00:00 2001 From: bcumming <bcumming@cscs.ch> Date: Tue, 7 Jun 2016 09:37:29 +0200 Subject: [PATCH] add timing to the ball_and_3stick validation test --- nrn/ball_and_3stick.py | 2 +- tests/util.hpp | 17 +++++++++++++++++ tests/validate_ball_and_stick.cpp | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nrn/ball_and_3stick.py b/nrn/ball_and_3stick.py index 3e777261..15ece3d3 100644 --- a/nrn/ball_and_3stick.py +++ b/nrn/ball_and_3stick.py @@ -89,7 +89,7 @@ for nseg in [5, 11, 51, 101] : # record spikes # this is a bit verbose, no? spike_counter_soma = h.APCount(soma(0.5)) - spike_counter_soma.thresh = -0 + spike_counter_soma.thresh = 0 spike_counter_dend = h.APCount(dend[0](1)) spike_counter_dend.thresh = -20 spike_counter_clamp = h.APCount(dend[1](1.0)) diff --git a/tests/util.hpp b/tests/util.hpp index b5e25d72..aeb2f8d3 100644 --- a/tests/util.hpp +++ b/tests/util.hpp @@ -3,6 +3,7 @@ #include <string> #include <vector> #include <iomanip> +#include <chrono> #include <cmath> @@ -14,6 +15,22 @@ namespace testing{ +using time_point = std::chrono::time_point<std::chrono::system_clock>; +using duration_type = std::chrono::duration<double>; + +static inline +time_point tic() +{ + return std::chrono::system_clock::now(); +} + +static inline +double toc(time_point start) +{ + return duration_type(tic() - start).count(); +} + + [[gnu::unused]] static void write_vis_file(const std::string& fname, std::vector<std::vector<double>> values) { diff --git a/tests/validate_ball_and_stick.cpp b/tests/validate_ball_and_stick.cpp index 024c7fdb..a2aef0ad 100644 --- a/tests/validate_ball_and_stick.cpp +++ b/tests/validate_ball_and_stick.cpp @@ -240,6 +240,7 @@ TEST(ball_and_3stick, neuron_baseline) }; std::vector<result> results; + auto start = testing::tic(); for(auto run_index=0u; run_index<cell_data.size(); ++run_index) { auto& run = cell_data[run_index]; int num_compartments = run["nseg"]; @@ -274,6 +275,8 @@ TEST(ball_and_3stick, neuron_baseline) results.push_back( {num_compartments, dt, v, measurements} ); } + auto time_taken = testing::toc(start); + std::cout << "took " << time_taken << " seconds\n"; // print results auto colors = {memory::util::kWhite, memory::util::kGreen, memory::util::kYellow}; -- GitLab