How to query lattice execution time#

We can query the lattice execution time after the workflow has been dispatched. First, we define the workflow as shown below.

import covalent as ct
import time

def add(x, y):
    return x + y

def multiply(x, y):
    return x * y

def workflow(x, y):
    res_1 = add(x=x, y=y)
    return multiply(x=res_1, y=y)

We dispatch the workflow and retrieve the results. The wait parameter is set to True so that the result is queried once the execution is completed. Following that, we can query the execution time as shown below.

dispatch_id = ct.dispatch(workflow)(x=2, y=3)
result = ct.get_result(dispatch_id=dispatch_id, wait=True)
print(f"Execution time: {(result.end_time - result.start_time).total_seconds():.2f} seconds")
Execution time: 1.06 seconds