|
17 | 17 | from inspect import signature |
18 | 18 | from itertools import chain |
19 | 19 | from numbers import Number |
20 | | -from time import perf_counter |
| 20 | +from time import perf_counter, perf_counter_ns |
21 | 21 | from typing import TYPE_CHECKING, Any, TypeAlias, TypeVar, cast |
22 | 22 |
|
23 | 23 | import numpy as np |
|
67 | 67 | log = logging.getLogger(__name__) |
68 | 68 | TRACER = trace.get_tracer(__name__) |
69 | 69 |
|
| 70 | + |
70 | 71 | ActionType = tuple[Callable[..., Any], Sequence[Any]] |
71 | 72 | SubscriberType = tuple[ |
72 | 73 | Callable[..., Any], MutableSequence[Any] | MutableMapping[Any, Any] |
@@ -98,6 +99,7 @@ def __init__( |
98 | 99 | ) -> None: |
99 | 100 | self._span = span |
100 | 101 | self._dataset = dataset |
| 102 | + self._add_result_time_ns = 0 |
101 | 103 | if ( |
102 | 104 | DataSaver.default_callback is not None |
103 | 105 | and "run_tables_subscription_callback" in DataSaver.default_callback |
@@ -207,6 +209,7 @@ def add_result(self, *result_tuples: ResType) -> None: |
207 | 209 | its type. |
208 | 210 |
|
209 | 211 | """ |
| 212 | + start_time = perf_counter_ns() |
210 | 213 |
|
211 | 214 | parameter_results: list[ParameterResultType] = [ |
212 | 215 | self._coerce_result_tuple_to_parameter_result_type(result_tuple) |
@@ -277,6 +280,7 @@ def add_result(self, *result_tuples: ResType) -> None: |
277 | 280 | if perf_counter() - self._last_save_time > self.write_period: |
278 | 281 | self.flush_data_to_database() |
279 | 282 | self._last_save_time = perf_counter() |
| 283 | + self._add_result_time_ns += perf_counter_ns() - start_time |
280 | 284 |
|
281 | 285 | def _unpack_arrayparameter( |
282 | 286 | self, partial_result: ResType |
@@ -734,6 +738,8 @@ def __exit__( |
734 | 738 | with DelayedKeyboardInterrupt( |
735 | 739 | context={"reason": "qcodes measurement exit", "qcodes_guid": self.ds.guid} |
736 | 740 | ): |
| 741 | + add_result_time = self.datasaver._add_result_time_ns |
| 742 | + self._span.set_attribute("qcodes_add_result_time_ms", add_result_time / 1e6) |
737 | 743 | self.datasaver.flush_data_to_database(block=True) |
738 | 744 |
|
739 | 745 | # perform the "teardown" events |
|
0 commit comments