NEURON
ftime.cpp
Go to the documentation of this file.
1 #include "oc_ansi.h"
2 
3 #include <chrono>
4 
5 static double start_time = 0.;
6 
7 double nrn_time() {
8  // Get nanoseconds converted in seconds
9  const auto now = std::chrono::time_point_cast<std::chrono::duration<double>>(
10  std::chrono::system_clock::now());
11  start_time = now.time_since_epoch().count();
12  return start_time;
13 }
14 
15 void hoc_startsw() {
16  hoc_ret();
18 }
19 
20 void hoc_stopsw() {
21  double now = nrn_time();
22  hoc_ret();
23  hoc_pushx(now - start_time);
24  start_time = now;
25 }
26 
27 double nrn_timeus() {
28  const auto now = std::chrono::time_point_cast<std::chrono::duration<double>>(
29  std::chrono::system_clock::now());
30  return now.time_since_epoch().count();
31 }
static double start_time
Definition: ftime.cpp:5
double nrn_time()
Definition: ftime.cpp:7
void hoc_startsw()
Definition: ftime.cpp:15
void hoc_stopsw()
Definition: ftime.cpp:20
double nrn_timeus()
Definition: ftime.cpp:27
void hoc_ret()
void hoc_pushx(double)
Definition: code.cpp:779
HOC interpreter function declarations (included by hocdec.h)