We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add cadenced runs for benchmarking slicing
## Description

The goal of this task is to ensure that any existing benchmarking tools are running as expected. And that the output of those tasks can be easily used to detect performance changes in napari.

## Motivation

Slicing is a core part of napari and it's critical that any changes to the related code does not substantially negatively impact performance of slicing. Many of the existing ASV benchmarks measure the time and memory used during layer initialization and slicing, which could be affect by this project.

## Output

The key output of this task is to have some way of easily detecting when the performance of napari changes at some regular interval (e.g. daily, weekly) based on the existing ASV benchmarks. This could be as simple as using `asv publish` after running `asv continuous` in the existing GitHub workflow to generate static HTML that can be downloaded and rendered locally. Alternatively, the report could be entirely text based as long as it's easy to find any changes in performance.

We should also have some way to trigger a full benchmark run for a PR related to async slicing that also generates a similar report, but that could be done in a follow-up PR. This task can also be broken down as needed.

## Notes
need to add workflow runs for benchmarking

Jaime can support

Relevant previous PRs
- https://github.com/napari/napari/pull/4554
- https://github.com/napari/napari/pull/4656


<hr>

### KCP update:

Issues with the `Benchmark` workflow have been resolved in https://github.com/napari/napari/pull/5083

Unfortunately I introduced a regression which I'm fixing in https://github.com/napari/napari/pull/5246

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `napari/benchmarks/benchmark_qt_slicing.py`
Content:
```
1 # See "Writing benchmarks" in the asv docs for more information.
2 # https://asv.readthedocs.io/en/latest/writing_benchmarks.html
3 # or the napari documentation on benchmarking
4 # https://github.com/napari/napari/blob/main/docs/BENCHMARKS.md
5 
6 import time
7 
8 import numpy as np
9 import zarr
10 from qtpy.QtWidgets import QApplication
11 
12 import napari
13 from napari.layers import Image
14 
15 SAMPLE_PARAMS = {
16     'skin_data': {
17         # napari-bio-sample-data
18         'shape': (1280, 960, 3),
19         'chunk_shape': (512, 512, 3),
20         'dtype': 'uint8',
21     },
22     'jrc_hela-2 (scale 3)': {
23         # s3://janelia-cosem-datasets/jrc_hela-2/jrc_hela-2.n5
24         'shape': (796, 200, 1500),
25         'dtype': 'uint16',
26         'chunk_shape': (64, 64, 64),
27     },
28 }
29 
30 
31 def get_image_params():
32     # chunksizes = [(64,64,64), (256,256,256), (512,512,512)]
33     latencies = [0.05 * i for i in range(0, 3)]
34     datanames = SAMPLE_PARAMS.keys()
35     params = (latencies, datanames)
36 
37     return params
38 
39 
40 class SlowMemoryStore(zarr.storage.MemoryStore):
41     def __init__(self, load_delay, *args, **kwargs):
42         self.load_delay = load_delay
43         super().__init__(*args, **kwargs)
44 
45     def __getitem__(self, item: str):
46         time.sleep(self.load_delay)
47         return super().__getitem__(item)
48 
49 
50 class AsyncImage2DSuite:
51     params = get_image_params()
52 
53     def setup(self, latency, dataname):
54         shape = SAMPLE_PARAMS[dataname]['shape']
55         chunk_shape = SAMPLE_PARAMS[dataname]['chunk_shape']
56         dtype = SAMPLE_PARAMS[dataname]['dtype']
57 
58         store = SlowMemoryStore(load_delay=latency)
59         self.data = zarr.zeros(
60             shape,
61             chunks=chunk_shape,
62             dtype=dtype,
63             store=store,
64         )
65 
66         self.layer = Image(self.data)
67 
68     def time_create_layer(self, *args):
69         """Time to create an image layer."""
70         Image(self.data)
71 
72     def time_set_view_slice(self, *args):
73         """Time to set view slice."""
74         self.layer._set_view_slice()
75 
76     def time_refresh(self, *args):
77         """Time to refresh view."""
78         self.layer.refresh()
79 
80 
81 class QtViewerAsyncImage2DSuite:
82     params = get_image_params()
83 
84     def setup(self, latency, dataname):
85         shape = SAMPLE_PARAMS[dataname]['shape']
86         chunk_shape = SAMPLE_PARAMS[dataname]['chunk_shape']
87         dtype = SAMPLE_PARAMS[dataname]['dtype']
88 
89         if len(shape) == 3 and shape[2] == 3:
90             # Skip 2D RGB tests -- scrolling does not apply
91             self.viewer = None
92             raise NotImplementedError
93 
94         store = SlowMemoryStore(load_delay=latency)
95         _ = QApplication.instance() or QApplication([])
96         self.data = zarr.zeros(
97             shape,
98             chunks=chunk_shape,
99             dtype=dtype,
100             store=store,
101         )
102 
103         self.viewer = napari.Viewer()
104         self.viewer.add_image(self.data)
105 
106     def time_z_scroll(self, *args):
107         layers_to_scroll = 4
108         for z in range(layers_to_scroll):
109             z = z * (self.data.shape[2] // layers_to_scroll)
110             self.viewer.dims.set_current_step(0, z)
111 
112     def teardown(self, *args):
113         if self.viewer is not None:
114             self.viewer.window.close()
115 
116 
117 class QtViewerAsyncPointsSuite:
118     n_points = [2**i for i in range(12, 18)]
119     params = n_points
120 
121     def setup(self, n_points):
122         _ = QApplication.instance() or QApplication([])
123 
124         np.random.seed(0)
125         self.viewer = napari.Viewer()
126         # Fake image layer to set bounds. Is this really needed?
127         self.empty_image = np.zeros((512, 512, 512), dtype="uint8")
128         self.viewer.add_image(self.empty_image)
129         self.point_data = np.random.randint(512, size=(n_points, 3))
130         self.viewer.add_points(self.point_data)
131 
132     def time_z_scroll(self, *args):
133         for z in range(self.empty_image.shape[0]):
134             self.viewer.dims.set_current_step(0, z)
135 
136     def teardown(self, *args):
137         self.viewer.window.close()
138 
139 
140 class QtViewerAsyncPointsAndImage2DSuite:
141     n_points = [2**i for i in range(12, 18, 2)]
142     chunksize = [256, 512, 1024]
143     latency = [0.05 * i for i in range(0, 3)]
144     params = (n_points, latency, chunksize)
145 
146     def setup(self, n_points, latency, chunksize):
147         store = SlowMemoryStore(load_delay=latency)
148         _ = QApplication.instance() or QApplication([])
149 
150         np.random.seed(0)
151 
152         self.image_data = zarr.zeros(
153             (64, 2048, 2048),
154             chunks=(1, chunksize, chunksize),
155             dtype='uint8',
156             store=store,
157         )
158 
159         self.viewer = napari.Viewer()
160         self.viewer.add_image(self.image_data)
161         self.point_data = np.random.randint(512, size=(n_points, 3))
162         self.viewer.add_points(self.point_data)
163 
164     def time_z_scroll(self, *args):
165         for z in range(self.image_data.shape[0]):
166             self.viewer.dims.set_current_step(0, z)
167 
168     def teardown(self, *args):
169         self.viewer.window.close()
170
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/napari/benchmarks/benchmark_qt_slicing.py b/napari/benchmarks/benchmark_qt_slicing.py
--- a/napari/benchmarks/benchmark_qt_slicing.py
+++ b/napari/benchmarks/benchmark_qt_slicing.py
@@ -48,7 +48,12 @@
 
 
 class AsyncImage2DSuite:
+    """TODO: these benchmarks are skipped. Remove the NotImplementedError in
+    setup to enable.
+    """
+
     params = get_image_params()
+    timeout = 300
 
     def setup(self, latency, dataname):
         shape = SAMPLE_PARAMS[dataname]['shape']
@@ -64,6 +69,7 @@
         )
 
         self.layer = Image(self.data)
+        raise NotImplementedError
 
     def time_create_layer(self, *args):
         """Time to create an image layer."""
@@ -79,7 +85,12 @@
 
 
 class QtViewerAsyncImage2DSuite:
+    """TODO: these benchmarks are skipped. Remove the NotImplementedError in
+    setup to enable.
+    """
+
     params = get_image_params()
+    timeout = 300
 
     def setup(self, latency, dataname):
         shape = SAMPLE_PARAMS[dataname]['shape']
@@ -102,6 +113,7 @@
 
         self.viewer = napari.Viewer()
         self.viewer.add_image(self.data)
+        raise NotImplementedError
 
     def time_z_scroll(self, *args):
         layers_to_scroll = 4
@@ -115,6 +127,10 @@
 
 
 class QtViewerAsyncPointsSuite:
+    """TODO: these benchmarks are skipped. Remove the NotImplementedError in
+    setup to enable.
+    """
+
     n_points = [2**i for i in range(12, 18)]
     params = n_points
 
@@ -128,6 +144,7 @@
         self.viewer.add_image(self.empty_image)
         self.point_data = np.random.randint(512, size=(n_points, 3))
         self.viewer.add_points(self.point_data)
+        raise NotImplementedError
 
     def time_z_scroll(self, *args):
         for z in range(self.empty_image.shape[0]):
@@ -138,10 +155,15 @@
 
 
 class QtViewerAsyncPointsAndImage2DSuite:
+    """TODO: these benchmarks are skipped. Remove the NotImplementedError in
+    setup to enable.
+    """
+
     n_points = [2**i for i in range(12, 18, 2)]
     chunksize = [256, 512, 1024]
     latency = [0.05 * i for i in range(0, 3)]
     params = (n_points, latency, chunksize)
+    timeout = 600
 
     def setup(self, n_points, latency, chunksize):
         store = SlowMemoryStore(load_delay=latency)
@@ -160,6 +182,7 @@
         self.viewer.add_image(self.image_data)
         self.point_data = np.random.randint(512, size=(n_points, 3))
         self.viewer.add_points(self.point_data)
+        raise NotImplementedError
 
     def time_z_scroll(self, *args):
         for z in range(self.image_data.shape[0]):

{"golden_diff": "diff --git a/napari/benchmarks/benchmark_qt_slicing.py b/napari/benchmarks/benchmark_qt_slicing.py\n--- a/napari/benchmarks/benchmark_qt_slicing.py\n+++ b/napari/benchmarks/benchmark_qt_slicing.py\n@@ -48,7 +48,12 @@\n \n \n class AsyncImage2DSuite:\n+    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n+    setup to enable.\n+    \"\"\"\n+\n     params = get_image_params()\n+    timeout = 300\n \n     def setup(self, latency, dataname):\n         shape = SAMPLE_PARAMS[dataname]['shape']\n@@ -64,6 +69,7 @@\n         )\n \n         self.layer = Image(self.data)\n+        raise NotImplementedError\n \n     def time_create_layer(self, *args):\n         \"\"\"Time to create an image layer.\"\"\"\n@@ -79,7 +85,12 @@\n \n \n class QtViewerAsyncImage2DSuite:\n+    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n+    setup to enable.\n+    \"\"\"\n+\n     params = get_image_params()\n+    timeout = 300\n \n     def setup(self, latency, dataname):\n         shape = SAMPLE_PARAMS[dataname]['shape']\n@@ -102,6 +113,7 @@\n \n         self.viewer = napari.Viewer()\n         self.viewer.add_image(self.data)\n+        raise NotImplementedError\n \n     def time_z_scroll(self, *args):\n         layers_to_scroll = 4\n@@ -115,6 +127,10 @@\n \n \n class QtViewerAsyncPointsSuite:\n+    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n+    setup to enable.\n+    \"\"\"\n+\n     n_points = [2**i for i in range(12, 18)]\n     params = n_points\n \n@@ -128,6 +144,7 @@\n         self.viewer.add_image(self.empty_image)\n         self.point_data = np.random.randint(512, size=(n_points, 3))\n         self.viewer.add_points(self.point_data)\n+        raise NotImplementedError\n \n     def time_z_scroll(self, *args):\n         for z in range(self.empty_image.shape[0]):\n@@ -138,10 +155,15 @@\n \n \n class QtViewerAsyncPointsAndImage2DSuite:\n+    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n+    setup to enable.\n+    \"\"\"\n+\n     n_points = [2**i for i in range(12, 18, 2)]\n     chunksize = [256, 512, 1024]\n     latency = [0.05 * i for i in range(0, 3)]\n     params = (n_points, latency, chunksize)\n+    timeout = 600\n \n     def setup(self, n_points, latency, chunksize):\n         store = SlowMemoryStore(load_delay=latency)\n@@ -160,6 +182,7 @@\n         self.viewer.add_image(self.image_data)\n         self.point_data = np.random.randint(512, size=(n_points, 3))\n         self.viewer.add_points(self.point_data)\n+        raise NotImplementedError\n \n     def time_z_scroll(self, *args):\n         for z in range(self.image_data.shape[0]):\n", "issue": "Add cadenced runs for benchmarking slicing\n## Description\n\nThe goal of this task is to ensure that any existing benchmarking tools are running as expected. And that the output of those tasks can be easily used to detect performance changes in napari.\n\n## Motivation\n\nSlicing is a core part of napari and it's critical that any changes to the related code does not substantially negatively impact performance of slicing. Many of the existing ASV benchmarks measure the time and memory used during layer initialization and slicing, which could be affect by this project.\n\n## Output\n\nThe key output of this task is to have some way of easily detecting when the performance of napari changes at some regular interval (e.g. daily, weekly) based on the existing ASV benchmarks. This could be as simple as using `asv publish` after running `asv continuous` in the existing GitHub workflow to generate static HTML that can be downloaded and rendered locally. Alternatively, the report could be entirely text based as long as it's easy to find any changes in performance.\n\nWe should also have some way to trigger a full benchmark run for a PR related to async slicing that also generates a similar report, but that could be done in a follow-up PR. This task can also be broken down as needed.\n\n## Notes\nneed to add workflow runs for benchmarking\n\nJaime can support\n\nRelevant previous PRs\n- https://github.com/napari/napari/pull/4554\n- https://github.com/napari/napari/pull/4656\n\n\n<hr>\n\n### KCP update:\n\nIssues with the `Benchmark` workflow have been resolved in https://github.com/napari/napari/pull/5083\n\nUnfortunately I introduced a regression which I'm fixing in https://github.com/napari/napari/pull/5246\n", "before_files": [{"content": "# See \"Writing benchmarks\" in the asv docs for more information.\n# https://asv.readthedocs.io/en/latest/writing_benchmarks.html\n# or the napari documentation on benchmarking\n# https://github.com/napari/napari/blob/main/docs/BENCHMARKS.md\n\nimport time\n\nimport numpy as np\nimport zarr\nfrom qtpy.QtWidgets import QApplication\n\nimport napari\nfrom napari.layers import Image\n\nSAMPLE_PARAMS = {\n    'skin_data': {\n        # napari-bio-sample-data\n        'shape': (1280, 960, 3),\n        'chunk_shape': (512, 512, 3),\n        'dtype': 'uint8',\n    },\n    'jrc_hela-2 (scale 3)': {\n        # s3://janelia-cosem-datasets/jrc_hela-2/jrc_hela-2.n5\n        'shape': (796, 200, 1500),\n        'dtype': 'uint16',\n        'chunk_shape': (64, 64, 64),\n    },\n}\n\n\ndef get_image_params():\n    # chunksizes = [(64,64,64), (256,256,256), (512,512,512)]\n    latencies = [0.05 * i for i in range(0, 3)]\n    datanames = SAMPLE_PARAMS.keys()\n    params = (latencies, datanames)\n\n    return params\n\n\nclass SlowMemoryStore(zarr.storage.MemoryStore):\n    def __init__(self, load_delay, *args, **kwargs):\n        self.load_delay = load_delay\n        super().__init__(*args, **kwargs)\n\n    def __getitem__(self, item: str):\n        time.sleep(self.load_delay)\n        return super().__getitem__(item)\n\n\nclass AsyncImage2DSuite:\n    params = get_image_params()\n\n    def setup(self, latency, dataname):\n        shape = SAMPLE_PARAMS[dataname]['shape']\n        chunk_shape = SAMPLE_PARAMS[dataname]['chunk_shape']\n        dtype = SAMPLE_PARAMS[dataname]['dtype']\n\n        store = SlowMemoryStore(load_delay=latency)\n        self.data = zarr.zeros(\n            shape,\n            chunks=chunk_shape,\n            dtype=dtype,\n            store=store,\n        )\n\n        self.layer = Image(self.data)\n\n    def time_create_layer(self, *args):\n        \"\"\"Time to create an image layer.\"\"\"\n        Image(self.data)\n\n    def time_set_view_slice(self, *args):\n        \"\"\"Time to set view slice.\"\"\"\n        self.layer._set_view_slice()\n\n    def time_refresh(self, *args):\n        \"\"\"Time to refresh view.\"\"\"\n        self.layer.refresh()\n\n\nclass QtViewerAsyncImage2DSuite:\n    params = get_image_params()\n\n    def setup(self, latency, dataname):\n        shape = SAMPLE_PARAMS[dataname]['shape']\n        chunk_shape = SAMPLE_PARAMS[dataname]['chunk_shape']\n        dtype = SAMPLE_PARAMS[dataname]['dtype']\n\n        if len(shape) == 3 and shape[2] == 3:\n            # Skip 2D RGB tests -- scrolling does not apply\n            self.viewer = None\n            raise NotImplementedError\n\n        store = SlowMemoryStore(load_delay=latency)\n        _ = QApplication.instance() or QApplication([])\n        self.data = zarr.zeros(\n            shape,\n            chunks=chunk_shape,\n            dtype=dtype,\n            store=store,\n        )\n\n        self.viewer = napari.Viewer()\n        self.viewer.add_image(self.data)\n\n    def time_z_scroll(self, *args):\n        layers_to_scroll = 4\n        for z in range(layers_to_scroll):\n            z = z * (self.data.shape[2] // layers_to_scroll)\n            self.viewer.dims.set_current_step(0, z)\n\n    def teardown(self, *args):\n        if self.viewer is not None:\n            self.viewer.window.close()\n\n\nclass QtViewerAsyncPointsSuite:\n    n_points = [2**i for i in range(12, 18)]\n    params = n_points\n\n    def setup(self, n_points):\n        _ = QApplication.instance() or QApplication([])\n\n        np.random.seed(0)\n        self.viewer = napari.Viewer()\n        # Fake image layer to set bounds. Is this really needed?\n        self.empty_image = np.zeros((512, 512, 512), dtype=\"uint8\")\n        self.viewer.add_image(self.empty_image)\n        self.point_data = np.random.randint(512, size=(n_points, 3))\n        self.viewer.add_points(self.point_data)\n\n    def time_z_scroll(self, *args):\n        for z in range(self.empty_image.shape[0]):\n            self.viewer.dims.set_current_step(0, z)\n\n    def teardown(self, *args):\n        self.viewer.window.close()\n\n\nclass QtViewerAsyncPointsAndImage2DSuite:\n    n_points = [2**i for i in range(12, 18, 2)]\n    chunksize = [256, 512, 1024]\n    latency = [0.05 * i for i in range(0, 3)]\n    params = (n_points, latency, chunksize)\n\n    def setup(self, n_points, latency, chunksize):\n        store = SlowMemoryStore(load_delay=latency)\n        _ = QApplication.instance() or QApplication([])\n\n        np.random.seed(0)\n\n        self.image_data = zarr.zeros(\n            (64, 2048, 2048),\n            chunks=(1, chunksize, chunksize),\n            dtype='uint8',\n            store=store,\n        )\n\n        self.viewer = napari.Viewer()\n        self.viewer.add_image(self.image_data)\n        self.point_data = np.random.randint(512, size=(n_points, 3))\n        self.viewer.add_points(self.point_data)\n\n    def time_z_scroll(self, *args):\n        for z in range(self.image_data.shape[0]):\n            self.viewer.dims.set_current_step(0, z)\n\n    def teardown(self, *args):\n        self.viewer.window.close()\n", "path": "napari/benchmarks/benchmark_qt_slicing.py"}], "after_files": [{"content": "# See \"Writing benchmarks\" in the asv docs for more information.\n# https://asv.readthedocs.io/en/latest/writing_benchmarks.html\n# or the napari documentation on benchmarking\n# https://github.com/napari/napari/blob/main/docs/BENCHMARKS.md\n\nimport time\n\nimport numpy as np\nimport zarr\nfrom qtpy.QtWidgets import QApplication\n\nimport napari\nfrom napari.layers import Image\n\nSAMPLE_PARAMS = {\n    'skin_data': {\n        # napari-bio-sample-data\n        'shape': (1280, 960, 3),\n        'chunk_shape': (512, 512, 3),\n        'dtype': 'uint8',\n    },\n    'jrc_hela-2 (scale 3)': {\n        # s3://janelia-cosem-datasets/jrc_hela-2/jrc_hela-2.n5\n        'shape': (796, 200, 1500),\n        'dtype': 'uint16',\n        'chunk_shape': (64, 64, 64),\n    },\n}\n\n\ndef get_image_params():\n    # chunksizes = [(64,64,64), (256,256,256), (512,512,512)]\n    latencies = [0.05 * i for i in range(0, 3)]\n    datanames = SAMPLE_PARAMS.keys()\n    params = (latencies, datanames)\n\n    return params\n\n\nclass SlowMemoryStore(zarr.storage.MemoryStore):\n    def __init__(self, load_delay, *args, **kwargs):\n        self.load_delay = load_delay\n        super().__init__(*args, **kwargs)\n\n    def __getitem__(self, item: str):\n        time.sleep(self.load_delay)\n        return super().__getitem__(item)\n\n\nclass AsyncImage2DSuite:\n    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n    setup to enable.\n    \"\"\"\n\n    params = get_image_params()\n    timeout = 300\n\n    def setup(self, latency, dataname):\n        shape = SAMPLE_PARAMS[dataname]['shape']\n        chunk_shape = SAMPLE_PARAMS[dataname]['chunk_shape']\n        dtype = SAMPLE_PARAMS[dataname]['dtype']\n\n        store = SlowMemoryStore(load_delay=latency)\n        self.data = zarr.zeros(\n            shape,\n            chunks=chunk_shape,\n            dtype=dtype,\n            store=store,\n        )\n\n        self.layer = Image(self.data)\n        raise NotImplementedError\n\n    def time_create_layer(self, *args):\n        \"\"\"Time to create an image layer.\"\"\"\n        Image(self.data)\n\n    def time_set_view_slice(self, *args):\n        \"\"\"Time to set view slice.\"\"\"\n        self.layer._set_view_slice()\n\n    def time_refresh(self, *args):\n        \"\"\"Time to refresh view.\"\"\"\n        self.layer.refresh()\n\n\nclass QtViewerAsyncImage2DSuite:\n    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n    setup to enable.\n    \"\"\"\n\n    params = get_image_params()\n    timeout = 300\n\n    def setup(self, latency, dataname):\n        shape = SAMPLE_PARAMS[dataname]['shape']\n        chunk_shape = SAMPLE_PARAMS[dataname]['chunk_shape']\n        dtype = SAMPLE_PARAMS[dataname]['dtype']\n\n        if len(shape) == 3 and shape[2] == 3:\n            # Skip 2D RGB tests -- scrolling does not apply\n            self.viewer = None\n            raise NotImplementedError\n\n        store = SlowMemoryStore(load_delay=latency)\n        _ = QApplication.instance() or QApplication([])\n        self.data = zarr.zeros(\n            shape,\n            chunks=chunk_shape,\n            dtype=dtype,\n            store=store,\n        )\n\n        self.viewer = napari.Viewer()\n        self.viewer.add_image(self.data)\n        raise NotImplementedError\n\n    def time_z_scroll(self, *args):\n        layers_to_scroll = 4\n        for z in range(layers_to_scroll):\n            z = z * (self.data.shape[2] // layers_to_scroll)\n            self.viewer.dims.set_current_step(0, z)\n\n    def teardown(self, *args):\n        if self.viewer is not None:\n            self.viewer.window.close()\n\n\nclass QtViewerAsyncPointsSuite:\n    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n    setup to enable.\n    \"\"\"\n\n    n_points = [2**i for i in range(12, 18)]\n    params = n_points\n\n    def setup(self, n_points):\n        _ = QApplication.instance() or QApplication([])\n\n        np.random.seed(0)\n        self.viewer = napari.Viewer()\n        # Fake image layer to set bounds. Is this really needed?\n        self.empty_image = np.zeros((512, 512, 512), dtype=\"uint8\")\n        self.viewer.add_image(self.empty_image)\n        self.point_data = np.random.randint(512, size=(n_points, 3))\n        self.viewer.add_points(self.point_data)\n        raise NotImplementedError\n\n    def time_z_scroll(self, *args):\n        for z in range(self.empty_image.shape[0]):\n            self.viewer.dims.set_current_step(0, z)\n\n    def teardown(self, *args):\n        self.viewer.window.close()\n\n\nclass QtViewerAsyncPointsAndImage2DSuite:\n    \"\"\"TODO: these benchmarks are skipped. Remove the NotImplementedError in\n    setup to enable.\n    \"\"\"\n\n    n_points = [2**i for i in range(12, 18, 2)]\n    chunksize = [256, 512, 1024]\n    latency = [0.05 * i for i in range(0, 3)]\n    params = (n_points, latency, chunksize)\n    timeout = 600\n\n    def setup(self, n_points, latency, chunksize):\n        store = SlowMemoryStore(load_delay=latency)\n        _ = QApplication.instance() or QApplication([])\n\n        np.random.seed(0)\n\n        self.image_data = zarr.zeros(\n            (64, 2048, 2048),\n            chunks=(1, chunksize, chunksize),\n            dtype='uint8',\n            store=store,\n        )\n\n        self.viewer = napari.Viewer()\n        self.viewer.add_image(self.image_data)\n        self.point_data = np.random.randint(512, size=(n_points, 3))\n        self.viewer.add_points(self.point_data)\n        raise NotImplementedError\n\n    def time_z_scroll(self, *args):\n        for z in range(self.image_data.shape[0]):\n            self.viewer.dims.set_current_step(0, z)\n\n    def teardown(self, *args):\n        self.viewer.window.close()\n", "path": "napari/benchmarks/benchmark_qt_slicing.py"}]}