Mantid
Loading...
Searching...
No Matches
AlgoTimeRegister.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9#include <boost/python/class.hpp>
10#include <boost/python/make_constructor.hpp>
11#include <boost/python/reference_existing_object.hpp>
12#include <boost/python/register_ptr_to_python.hpp>
13#include <boost/python/return_value_policy.hpp>
14
15using namespace Mantid::Instrumentation;
16using namespace boost::python;
18
19void addTimeWrapper(const std::string &name, size_t begin, size_t end) {
20
21 std::chrono::nanoseconds begin_ns(begin);
22 std::chrono::nanoseconds end_ns(end);
23
24 // calculate the start time timepoint
25 std::chrono::time_point<std::chrono::high_resolution_clock> tp_begin_ns(begin_ns);
26
27 // calculate the end time timepoint
28 std::chrono::time_point<std::chrono::high_resolution_clock> tp_end_ns(end_ns);
29
30 Mantid::Instrumentation::AlgoTimeRegister::Instance().addTime(name, tp_begin_ns, tp_end_ns);
31}
32
34
35 // AlgoTimeRegister class
36 class_<AlgoTimeRegisterImpl, boost::noncopyable>("AlgoTimeRegisterImpl", no_init)
37 .def("addTime", &addTimeWrapper, (arg("name"), arg("begin"), arg("end")),
38 "Adds a time entry in the file for a function with <name> that starts at <begin> time_ns and ends at <end> "
39 "time_ns relative to the <START_POINT> clock")
40 .staticmethod("addTime")
41 .def("Instance", &AlgoTimeRegister::Instance, return_value_policy<reference_existing_object>(),
42 "Returns a reference to the AlgoTimeRegister")
43 .staticmethod("Instance");
44}
std::string name
Definition Run.cpp:60
void addTimeWrapper(const std::string &name, size_t begin, size_t end)
void export_AlgoTimeRegister()
std::chrono::time_point< std::chrono::high_resolution_clock > time_point_ns
Definition Algorithm.h:39