diff --git a/benchmarks/scripts.py b/benchmarks/scripts.py index f3b9708..a1cb2cf 100644 --- a/benchmarks/scripts.py +++ b/benchmarks/scripts.py @@ -55,10 +55,18 @@ def circuit_benchmark(nqubits, backend, circuit_name, circuit_options=None, result = result.numpy() logs.log(dry_run_transfer_time=time.time() - start_time) dtype = str(result.state().dtype) - del(result) + del result + del circuit - simulation_times, transfer_times = [], [] + creation_times, simulation_times, transfer_times = [], [], [] for _ in range(nreps): + start_time = time.time() + circuit = qibo.models.Circuit(nqubits) + circuit.add(gates) + if nshots is not None: + # add measurement gates + circuit.add(qibo.gates.M(*range(nqubits))) + creation_times.append(time.time() - start_time) start_time = time.time() result = circuit(nshots=nshots) simulation_times.append(time.time() - start_time) @@ -66,10 +74,13 @@ def circuit_benchmark(nqubits, backend, circuit_name, circuit_options=None, if transfer: result = result.numpy() transfer_times.append(time.time() - start_time) - del(result) + del result + del circuit - logs.log(dtype=dtype, simulation_times=simulation_times, + logs.log(dtype=dtype, creation_times=creation_times, + simulation_times=simulation_times, transfer_times=transfer_times) + logs.average("creation_times") logs.average("simulation_times") logs.average("transfer_times") @@ -120,14 +131,14 @@ def library_benchmark(nqubits, library, circuit_name, circuit_options=None, result = backend(circuit) logs.log(dry_run_time=time.time() - start_time) dtype = str(result.dtype) - del(result) + del result simulation_times = [] for _ in range(nreps): start_time = time.time() result = backend(circuit) simulation_times.append(time.time() - start_time) - del(result) + del result logs.log(dtype=dtype, simulation_times=simulation_times) logs.average("simulation_times") @@ -169,7 +180,7 @@ def evolution_benchmark(nqubits, dt, solver, backend, platform=None, result = evolution(final_time=1.0) logs.log(dry_run_time=time.time() - start_time) dtype = str(result.dtype) - del(result) + del result simulation_times = [] for _ in range(nreps):