Using Timing Information: SAPI Clients¶
This section is relevant to users of the C, MATLAB, and Python client libraries. If you are using the dwave-cloud-client in the Ocean SDK instead, see Using Timing Information: dwave-cloud-client.
Timing Data Returned by SAPI Clients¶
Below is a sample skeleton of Python code for accessing timing data returned by SAPI. Timing values are returned in the status object and the timing object; further code could query those objects in more detail. The timing object referenced on line 10 is a Python dictionary containing (key, value) pairs. The keys match keywords discussed in this section.
01 from dwave_sapi2.local import local_connection 02 from dwave_sapi2.core import async_solve_ising, await_completion 03 import datetime 04 h,J = build_hamiltonian() 05 solver = local_connection.get_solver('example_solver') 06 submitted_qmi = async_solve_ising(solver, h, J, num_reads=100) 07 await_completion([submitted_qmi], min_done=2, timeout=1.0) 08 # QPU and PP times 09 result = submitted_qmi.result() 10 timing = result['timing'] 11 # Service time 12 time_format = "%Y-%m-%dT%H:%M:%S.%fZ" 13 status = submitted_qmi.status() 14 start_time = datetime.datetime.strptime(status ['time_received'], time_format) 15 finish_time = datetime.datetime.strptime(status['time_solved'], time_format) 16 service_time = finish_time - start_time