def wrapper(*args, **kwargs): timer = ProcessTimer() retval = wrapped(*args, **kwargs) timer.done() future = DummyTimingFuture.from_timer(timer) return (retval, future)
class DebugTimer(object): def __init__(self, verbose=False): self.ptimer = ProcessTimer() self.verbose = verbose def __enter__(self): self.ptimer = ProcessTimer() self.ptimer.__enter__() def __exit__(self, exc_type, exc_val, exc_tb): self.ptimer.__exit__(exc_type, exc_val, exc_tb) if self.verbose: print(f"Process elapsed: {self.ptimer.process_elapsed}") print(f"Wall elapsed: {self.ptimer.wall_elapsed}") @property def proc_elapsed(self): return self.ptimer.process_elapsed @property def wall_elapsed(self): return self.ptimer.wall_elapsed
def test_derivative_binder_expr(): logging.basicConfig(level=logging.INFO) ambient_dim = 3 dim = ambient_dim - 1 from pytential.symbolic.mappers import DerivativeBinder d1, d2 = principal_directions(ambient_dim, dim=dim) expr = (d1 @ d2 + d1 @ d1) / (d2 @ d2) nruns = 4 for i in range(nruns): from pytools import ProcessTimer with ProcessTimer() as pd: new_expr = DerivativeBinder()(expr) logger.info("time: [%04d/%04d] bind [%s] (%s)", i, nruns, pd, expr is new_expr) assert expr is new_expr
discr = reconstruct_discr_from_nodes(actx, discr0, x) vis = make_visualizer(actx, discr, vis_order=target_order) # vis = vis.copy_with_same_connectivity(actx, discr) filename = f"moving-geometry-{n:09d}.vtu" plot_solution(actx, vis, filename, discr, t, x) logger.info("[%05d/%05d] t = %.5e/%.5e dt = %.5e", n, maxiter, t, tmax, dt) # }}} if __name__ == "__main__": cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) actx = PyOpenCLArrayContext(queue) from pytools import ProcessTimer for _ in range(1): with ProcessTimer() as p: run(actx, ambient_dim=3, group_factory_name="warp_and_blend", tmax=1.0, timestep=1.0e-2, visualize=False) logger.info("elapsed: %.3fs wall %.2fx cpu", p.wall_elapsed, p.process_elapsed / p.wall_elapsed)
def __enter__(self): self.ptimer = ProcessTimer() self.ptimer.__enter__()
def __init__(self, verbose=False): self.ptimer = ProcessTimer() self.verbose = verbose