mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
export PajeTrace to Python (with context manager api)
This commit is contained in:
parent
f9ff1db7c3
commit
b272614a51
@ -246,4 +246,25 @@ threads : int
|
||||
.def("__timing__", &TaskManager::Timing)
|
||||
;
|
||||
|
||||
py::class_<PajeTrace>(m, "PajeTrace")
|
||||
.def(py::init( [] (string filename, size_t size_mb, bool threads, bool thread_counter)
|
||||
{
|
||||
PajeTrace::SetMaxTracefileSize(size_mb*1014*1024);
|
||||
PajeTrace::SetTraceThreads(threads);
|
||||
PajeTrace::SetTraceThreadCounter(thread_counter);
|
||||
trace = new PajeTrace(TaskManager::GetMaxThreads(), filename);
|
||||
return trace;
|
||||
}), py::arg("filename")="ng.trace", py::arg("size")=1000,
|
||||
py::arg("threads")=true, py::arg("thread_counter")=false,
|
||||
"size in Megabytes"
|
||||
)
|
||||
.def("__enter__", [](PajeTrace & self) { })
|
||||
.def("__exit__", [](PajeTrace & self, py::args) { self.StopTracing(); })
|
||||
.def("__del__", [](PajeTrace & self) { trace = nullptr; })
|
||||
.def("SetTraceThreads", &PajeTrace::SetTraceThreads)
|
||||
.def("SetTraceThreadCounter", &PajeTrace::SetTraceThreadCounter)
|
||||
.def("SetMaxTracefileSize", &PajeTrace::SetMaxTracefileSize)
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
|
@ -166,8 +166,11 @@ namespace ngcore
|
||||
|
||||
TaskManager :: ~TaskManager ()
|
||||
{
|
||||
delete trace;
|
||||
trace = nullptr;
|
||||
if (use_paje_trace)
|
||||
{
|
||||
delete trace;
|
||||
trace = nullptr;
|
||||
}
|
||||
num_threads = 1;
|
||||
}
|
||||
|
||||
@ -335,7 +338,7 @@ namespace ngcore
|
||||
}
|
||||
|
||||
|
||||
if (use_paje_trace)
|
||||
if (trace)
|
||||
trace->StartJob(jobnr, afunc.target_type());
|
||||
|
||||
func = &afunc;
|
||||
@ -406,7 +409,7 @@ namespace ngcore
|
||||
if (ex)
|
||||
throw Exception (*ex);
|
||||
|
||||
if (use_paje_trace)
|
||||
if (trace)
|
||||
trace->StopJob();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user