Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Framework/API/src/AlgoTimeRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ AlgoTimeRegisterImpl::AlgoTimeRegisterImpl()
AlgoTimeRegisterImpl::~AlgoTimeRegisterImpl() {}

} // namespace Instrumentation
} // namespace Mantid
} // namespace Mantid
4 changes: 4 additions & 0 deletions Framework/PythonInterface/mantid/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ set(EXPORT_FILES
src/Exports/RegionSelectorObserver.cpp
)

if(PROFILE_ALGORITHM_LINUX)
set(EXPORT_FILES "${EXPORT_FILES}" "src/Exports/AlgoTimeRegister.cpp")
endif()

set(MODULE_DEFINITION ${CMAKE_CURRENT_BINARY_DIR}/api.cpp)
create_module(${MODULE_TEMPLATE} ${MODULE_DEFINITION} ${EXPORT_FILES})

Expand Down
8 changes: 8 additions & 0 deletions Framework/PythonInterface/mantid/api/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Defines a set of aliases to make accessing certain objects easier
"""

import sys

from mantid.api import (
AlgorithmFactoryImpl,
AlgorithmManagerImpl,
Expand Down Expand Up @@ -41,6 +43,12 @@
FunctionFactory = lazy_instance_access(FunctionFactoryImpl)
WorkspaceFactory = lazy_instance_access(WorkspaceFactoryImpl)
CatalogManager = lazy_instance_access(CatalogManagerImpl)
if sys.platform.startswith("linux"):
try:
from mantid.api import AlgoTimeRegisterImpl

AlgoTimeRegister = lazy_instance_access(AlgoTimeRegisterImpl)
except:
AlgoTimeRegister = None
# backwards-compatible
mtd = AnalysisDataService
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/AlgoTimeRegister.h"
#include "MantidKernel/Timer.h"
#include <boost/python/class.hpp>
#include <boost/python/make_constructor.hpp>
#include <boost/python/reference_existing_object.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/return_value_policy.hpp>

using namespace Mantid::Instrumentation;
using namespace boost::python;
using Mantid::Kernel::time_point_ns;

void addTimeWrapper(const std::string &name, long int begin, long int end) {

std::chrono::nanoseconds begin_ns(begin);
std::chrono::nanoseconds end_ns(end);

// calculate the start time timepoint
std::chrono::time_point<std::chrono::high_resolution_clock> tp_begin_ns(begin_ns);

// calculate the end time timepoint
std::chrono::time_point<std::chrono::high_resolution_clock> tp_end_ns(end_ns);

Mantid::Instrumentation::AlgoTimeRegister::Instance().addTime(name, tp_begin_ns, tp_end_ns);
}

void export_AlgoTimeRegister() {

// AlgoTimeRegister class
class_<AlgoTimeRegisterImpl, boost::noncopyable>("AlgoTimeRegisterImpl", no_init)
.def("addTime", &addTimeWrapper, (arg("name"), arg("begin"), arg("end")),
"Adds a time entry in the file for a function with <name> that starts at <begin> time_ns and ends at <end> "
"time_ns relative to the <START_POINT> clock")
.staticmethod("addTime")
.def("Instance", &AlgoTimeRegister::Instance, return_value_policy<reference_existing_object>(),
"Returns a reference to the AlgoTimeRegister")
.staticmethod("Instance");
}
Loading
Loading