I want to record the time that a VQE solver takes to find the ground state. At the moment I am using:
%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
import numpy as np
import matplotlib.pyplot as plt
import time
# Loading your IBM Q account(s) and assigning backend
IBMQ.load_account()
provider = IBMQ.get_provider('ibm-q')
qcomp = provider.get_backend('ibmq_valencia')
#Imports for algorithm
from qiskit.chemistry.drivers import PySCFDriver, UnitsType, Molecule
from qiskit.chemistry.transformations import FermionicTransformation, FermionicQubitMappingType
from qiskit.aqua.algorithms import NumPyMinimumEigensolver
from qiskit import BasicAer
from qiskit.aqua import QuantumInstance
from qiskit.chemistry.algorithms.ground_state_solvers.minimum_eigensolver_factories import VQEUCCSDFactory
from qiskit.chemistry.algorithms.ground_state_solvers import GroundStateEigensolver
#Define molecule
molecule = Molecule(geometry=[['H', [0., 0., 0.]],
['H', [0., 0., 0.735]]],
charge=0, multiplicity=1)
driver = PySCFDriver(molecule = molecule, unit=UnitsType.ANGSTROM, basis='sto3g')
#Map fermionic hamiltonian to qubit hamiltonian
transformation = FermionicTransformation(qubit_mapping=FermionicQubitMappingType.PARITY,
two_qubit_reduction=True,
freeze_core=True)
#Initialize the VQE solver
vqe_solver = VQEUCCSDFactory(QuantumInstance(backend = qcomp))
#Ground state algorithm
calculation_VQE = GroundStateEigensolver(transformation, vqe_solver)
#Calculate results
start = time.time()
VQE_result = calculation_VQE.solve(driver)
end = time.time()
time_difference = (end - start)
print(VQE_result.total_energies)
print(time_difference)
However, after running this a few times on different IBM quantum machines, I am quite sure that the times I am recording are including the time spent waiting in queue to run the computations (but not completely certain on this). Is there any way to record the time taken by the VQE to compute the ground state energy without including queue time.