mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +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)
|
.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)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -165,9 +165,12 @@ namespace ngcore
|
|||||||
|
|
||||||
|
|
||||||
TaskManager :: ~TaskManager ()
|
TaskManager :: ~TaskManager ()
|
||||||
|
{
|
||||||
|
if (use_paje_trace)
|
||||||
{
|
{
|
||||||
delete trace;
|
delete trace;
|
||||||
trace = nullptr;
|
trace = nullptr;
|
||||||
|
}
|
||||||
num_threads = 1;
|
num_threads = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +338,7 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (use_paje_trace)
|
if (trace)
|
||||||
trace->StartJob(jobnr, afunc.target_type());
|
trace->StartJob(jobnr, afunc.target_type());
|
||||||
|
|
||||||
func = &afunc;
|
func = &afunc;
|
||||||
@ -406,7 +409,7 @@ namespace ngcore
|
|||||||
if (ex)
|
if (ex)
|
||||||
throw Exception (*ex);
|
throw Exception (*ex);
|
||||||
|
|
||||||
if (use_paje_trace)
|
if (trace)
|
||||||
trace->StopJob();
|
trace->StopJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user