We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Adding `elapsed` property to Timer event?
`event.elapsed` would be a shortcut to ~~`event.dt * event.iteration`~~. Actually it's a bit more complicated because `event.dt` is not constant, so it should rather be the sum of all `event.dt`s.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `vispy/app/timer.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2014, Vispy Development Team.
3 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
4 
5 from __future__ import division
6 
7 from ..util.event import Event, EmitterGroup
8 from ..util.ptime import time as precision_time
9 from ..ext.six import string_types
10 from .base import BaseTimerBackend as TimerBackend  # noqa
11 from . import use_app, Application
12 
13 
14 class Timer(object):
15 
16     """Timer used to schedule events in the future or on a repeating schedule
17 
18     Parameters
19     ----------
20     interval : float
21         Time between events.
22     connect : function | None
23         The function to call.
24     iterations : int
25         Number of iterations. Can be -1 for infinite.
26     start : bool
27         Whether to start the timer.
28     app : instance of vispy.app.Application
29         The application to attach the timer to.
30     """
31 
32     def __init__(self, interval=0.0, connect=None, iterations=-1, start=False,
33                  app=None):
34         self.events = EmitterGroup(source=self,
35                                    start=Event,
36                                    stop=Event,
37                                    timeout=Event)
38         #self.connect = self.events.timeout.connect
39         #self.disconnect = self.events.timeout.disconnect
40 
41         # Get app instance
42         if app is None:
43             self._app = use_app()
44         elif isinstance(app, Application):
45             self._app = app
46         elif isinstance(app, string_types):
47             self._app = Application(app)
48         else:
49             raise ValueError('Invalid value for app %r' % app)
50         
51         # Ensure app has backend app object
52         self._app.native
53         
54         # Instantiate the backed with the right class
55         self._backend = self._app.backend_module.TimerBackend(self)
56 
57         self._interval = interval
58         self._running = False
59         self._last_emit_time = None
60         self.iter_count = 0
61         self.max_iterations = iterations
62         if connect is not None:
63             self.connect(connect)
64         if start:
65             self.start()
66 
67     @property
68     def app(self):
69         """ The vispy Application instance on which this Timer is based.
70         """
71         return self._app
72 
73     @property
74     def interval(self):
75         return self._interval
76 
77     @interval.setter
78     def interval(self, val):
79         self._interval = val
80         if self.running:
81             self.stop()
82             self.start()
83 
84     @property
85     def running(self):
86         return self._running
87 
88     def start(self, interval=None, iterations=None):
89         """Start the timer.
90 
91         A timeout event will be generated every *interval* seconds.
92         If *interval* is None, then self.interval will be used.
93 
94         If *iterations* is specified, the timer will stop after
95         emitting that number of events. If unspecified, then
96         the previous value of self.iterations will be used. If the value is
97         negative, then the timer will continue running until stop() is called.
98         """
99         self.iter_count = 0
100         if interval is not None:
101             self.interval = interval
102         if iterations is not None:
103             self.max_iterations = iterations
104         self._backend._vispy_start(self.interval)
105         self._running = True
106         self._last_emit_time = precision_time()
107         self.events.start(type='timer_start')
108 
109     def stop(self):
110         """Stop the timer."""
111         self._backend._vispy_stop()
112         self._running = False
113         self.events.stop(type='timer_stop')
114 
115     # use timer.app.run() and .quit() instead.
116     # def run_event_loop(self):
117         #"""Execute the event loop for this Timer's backend.
118         #"""
119         # return self._backend._vispy_run()
120 
121     # def quit_event_loop(self):
122         #"""Exit the event loop for this Timer's backend.
123         #"""
124         # return self._backend._vispy_quit()
125 
126     @property
127     def native(self):
128         """ The native timer on which this Timer is based.
129         """
130         return self._backend._vispy_get_native_timer()
131 
132     def _timeout(self, *args):
133         # called when the backend timer has triggered.
134         if not self.running:
135             return
136         if self.max_iterations >= 0 and self.iter_count >= self.max_iterations:
137             self.stop()
138             return
139 
140         # compute dt since last event
141         now = precision_time()
142         dt = now - self._last_emit_time
143         self._last_emit_time = now
144 
145         self.events.timeout(
146             type='timer_timeout',
147             iteration=self.iter_count,
148             dt=dt)
149         self.iter_count += 1
150 
151     def connect(self, callback):
152         """ Alias for self.events.timeout.connect() """
153         return self.events.timeout.connect(callback)
154 
155     def disconnect(self, callback=None):
156         """ Alias for self.events.timeout.disconnect() """
157         return self.events.timeout.disconnect(callback)
158
```
--- 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/vispy/app/timer.py b/vispy/app/timer.py
--- a/vispy/app/timer.py
+++ b/vispy/app/timer.py
@@ -56,6 +56,7 @@
 
         self._interval = interval
         self._running = False
+        self._first_emit_time = None
         self._last_emit_time = None
         self.iter_count = 0
         self.max_iterations = iterations
@@ -81,6 +82,10 @@
             self.stop()
             self.start()
 
+    @property
+    def elapsed(self):
+        return precision_time() - self._first_emit_time
+
     @property
     def running(self):
         return self._running
@@ -103,6 +108,7 @@
             self.max_iterations = iterations
         self._backend._vispy_start(self.interval)
         self._running = True
+        self._first_emit_time = precision_time()
         self._last_emit_time = precision_time()
         self.events.start(type='timer_start')
 
@@ -140,11 +146,13 @@
         # compute dt since last event
         now = precision_time()
         dt = now - self._last_emit_time
+        elapsed = now - self._first_emit_time
         self._last_emit_time = now
 
         self.events.timeout(
             type='timer_timeout',
             iteration=self.iter_count,
+            elapsed=elapsed,
             dt=dt)
         self.iter_count += 1

{"golden_diff": "diff --git a/vispy/app/timer.py b/vispy/app/timer.py\n--- a/vispy/app/timer.py\n+++ b/vispy/app/timer.py\n@@ -56,6 +56,7 @@\n \n         self._interval = interval\n         self._running = False\n+        self._first_emit_time = None\n         self._last_emit_time = None\n         self.iter_count = 0\n         self.max_iterations = iterations\n@@ -81,6 +82,10 @@\n             self.stop()\n             self.start()\n \n+    @property\n+    def elapsed(self):\n+        return precision_time() - self._first_emit_time\n+\n     @property\n     def running(self):\n         return self._running\n@@ -103,6 +108,7 @@\n             self.max_iterations = iterations\n         self._backend._vispy_start(self.interval)\n         self._running = True\n+        self._first_emit_time = precision_time()\n         self._last_emit_time = precision_time()\n         self.events.start(type='timer_start')\n \n@@ -140,11 +146,13 @@\n         # compute dt since last event\n         now = precision_time()\n         dt = now - self._last_emit_time\n+        elapsed = now - self._first_emit_time\n         self._last_emit_time = now\n \n         self.events.timeout(\n             type='timer_timeout',\n             iteration=self.iter_count,\n+            elapsed=elapsed,\n             dt=dt)\n         self.iter_count += 1\n", "issue": "Adding `elapsed` property to Timer event?\n`event.elapsed` would be a shortcut to ~~`event.dt * event.iteration`~~. Actually it's a bit more complicated because `event.dt` is not constant, so it should rather be the sum of all `event.dt`s.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2014, Vispy Development Team.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n\nfrom __future__ import division\n\nfrom ..util.event import Event, EmitterGroup\nfrom ..util.ptime import time as precision_time\nfrom ..ext.six import string_types\nfrom .base import BaseTimerBackend as TimerBackend  # noqa\nfrom . import use_app, Application\n\n\nclass Timer(object):\n\n    \"\"\"Timer used to schedule events in the future or on a repeating schedule\n\n    Parameters\n    ----------\n    interval : float\n        Time between events.\n    connect : function | None\n        The function to call.\n    iterations : int\n        Number of iterations. Can be -1 for infinite.\n    start : bool\n        Whether to start the timer.\n    app : instance of vispy.app.Application\n        The application to attach the timer to.\n    \"\"\"\n\n    def __init__(self, interval=0.0, connect=None, iterations=-1, start=False,\n                 app=None):\n        self.events = EmitterGroup(source=self,\n                                   start=Event,\n                                   stop=Event,\n                                   timeout=Event)\n        #self.connect = self.events.timeout.connect\n        #self.disconnect = self.events.timeout.disconnect\n\n        # Get app instance\n        if app is None:\n            self._app = use_app()\n        elif isinstance(app, Application):\n            self._app = app\n        elif isinstance(app, string_types):\n            self._app = Application(app)\n        else:\n            raise ValueError('Invalid value for app %r' % app)\n        \n        # Ensure app has backend app object\n        self._app.native\n        \n        # Instantiate the backed with the right class\n        self._backend = self._app.backend_module.TimerBackend(self)\n\n        self._interval = interval\n        self._running = False\n        self._last_emit_time = None\n        self.iter_count = 0\n        self.max_iterations = iterations\n        if connect is not None:\n            self.connect(connect)\n        if start:\n            self.start()\n\n    @property\n    def app(self):\n        \"\"\" The vispy Application instance on which this Timer is based.\n        \"\"\"\n        return self._app\n\n    @property\n    def interval(self):\n        return self._interval\n\n    @interval.setter\n    def interval(self, val):\n        self._interval = val\n        if self.running:\n            self.stop()\n            self.start()\n\n    @property\n    def running(self):\n        return self._running\n\n    def start(self, interval=None, iterations=None):\n        \"\"\"Start the timer.\n\n        A timeout event will be generated every *interval* seconds.\n        If *interval* is None, then self.interval will be used.\n\n        If *iterations* is specified, the timer will stop after\n        emitting that number of events. If unspecified, then\n        the previous value of self.iterations will be used. If the value is\n        negative, then the timer will continue running until stop() is called.\n        \"\"\"\n        self.iter_count = 0\n        if interval is not None:\n            self.interval = interval\n        if iterations is not None:\n            self.max_iterations = iterations\n        self._backend._vispy_start(self.interval)\n        self._running = True\n        self._last_emit_time = precision_time()\n        self.events.start(type='timer_start')\n\n    def stop(self):\n        \"\"\"Stop the timer.\"\"\"\n        self._backend._vispy_stop()\n        self._running = False\n        self.events.stop(type='timer_stop')\n\n    # use timer.app.run() and .quit() instead.\n    # def run_event_loop(self):\n        #\"\"\"Execute the event loop for this Timer's backend.\n        #\"\"\"\n        # return self._backend._vispy_run()\n\n    # def quit_event_loop(self):\n        #\"\"\"Exit the event loop for this Timer's backend.\n        #\"\"\"\n        # return self._backend._vispy_quit()\n\n    @property\n    def native(self):\n        \"\"\" The native timer on which this Timer is based.\n        \"\"\"\n        return self._backend._vispy_get_native_timer()\n\n    def _timeout(self, *args):\n        # called when the backend timer has triggered.\n        if not self.running:\n            return\n        if self.max_iterations >= 0 and self.iter_count >= self.max_iterations:\n            self.stop()\n            return\n\n        # compute dt since last event\n        now = precision_time()\n        dt = now - self._last_emit_time\n        self._last_emit_time = now\n\n        self.events.timeout(\n            type='timer_timeout',\n            iteration=self.iter_count,\n            dt=dt)\n        self.iter_count += 1\n\n    def connect(self, callback):\n        \"\"\" Alias for self.events.timeout.connect() \"\"\"\n        return self.events.timeout.connect(callback)\n\n    def disconnect(self, callback=None):\n        \"\"\" Alias for self.events.timeout.disconnect() \"\"\"\n        return self.events.timeout.disconnect(callback)\n", "path": "vispy/app/timer.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2014, Vispy Development Team.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n\nfrom __future__ import division\n\nfrom ..util.event import Event, EmitterGroup\nfrom ..util.ptime import time as precision_time\nfrom ..ext.six import string_types\nfrom .base import BaseTimerBackend as TimerBackend  # noqa\nfrom . import use_app, Application\n\n\nclass Timer(object):\n\n    \"\"\"Timer used to schedule events in the future or on a repeating schedule\n\n    Parameters\n    ----------\n    interval : float\n        Time between events.\n    connect : function | None\n        The function to call.\n    iterations : int\n        Number of iterations. Can be -1 for infinite.\n    start : bool\n        Whether to start the timer.\n    app : instance of vispy.app.Application\n        The application to attach the timer to.\n    \"\"\"\n\n    def __init__(self, interval=0.0, connect=None, iterations=-1, start=False,\n                 app=None):\n        self.events = EmitterGroup(source=self,\n                                   start=Event,\n                                   stop=Event,\n                                   timeout=Event)\n        #self.connect = self.events.timeout.connect\n        #self.disconnect = self.events.timeout.disconnect\n\n        # Get app instance\n        if app is None:\n            self._app = use_app()\n        elif isinstance(app, Application):\n            self._app = app\n        elif isinstance(app, string_types):\n            self._app = Application(app)\n        else:\n            raise ValueError('Invalid value for app %r' % app)\n        \n        # Ensure app has backend app object\n        self._app.native\n        \n        # Instantiate the backed with the right class\n        self._backend = self._app.backend_module.TimerBackend(self)\n\n        self._interval = interval\n        self._running = False\n        self._first_emit_time = None\n        self._last_emit_time = None\n        self.iter_count = 0\n        self.max_iterations = iterations\n        if connect is not None:\n            self.connect(connect)\n        if start:\n            self.start()\n\n    @property\n    def app(self):\n        \"\"\" The vispy Application instance on which this Timer is based.\n        \"\"\"\n        return self._app\n\n    @property\n    def interval(self):\n        return self._interval\n\n    @interval.setter\n    def interval(self, val):\n        self._interval = val\n        if self.running:\n            self.stop()\n            self.start()\n\n    @property\n    def elapsed(self):\n        return precision_time() - self._first_emit_time\n\n    @property\n    def running(self):\n        return self._running\n\n    def start(self, interval=None, iterations=None):\n        \"\"\"Start the timer.\n\n        A timeout event will be generated every *interval* seconds.\n        If *interval* is None, then self.interval will be used.\n\n        If *iterations* is specified, the timer will stop after\n        emitting that number of events. If unspecified, then\n        the previous value of self.iterations will be used. If the value is\n        negative, then the timer will continue running until stop() is called.\n        \"\"\"\n        self.iter_count = 0\n        if interval is not None:\n            self.interval = interval\n        if iterations is not None:\n            self.max_iterations = iterations\n        self._backend._vispy_start(self.interval)\n        self._running = True\n        self._first_emit_time = precision_time()\n        self._last_emit_time = precision_time()\n        self.events.start(type='timer_start')\n\n    def stop(self):\n        \"\"\"Stop the timer.\"\"\"\n        self._backend._vispy_stop()\n        self._running = False\n        self.events.stop(type='timer_stop')\n\n    # use timer.app.run() and .quit() instead.\n    # def run_event_loop(self):\n        #\"\"\"Execute the event loop for this Timer's backend.\n        #\"\"\"\n        # return self._backend._vispy_run()\n\n    # def quit_event_loop(self):\n        #\"\"\"Exit the event loop for this Timer's backend.\n        #\"\"\"\n        # return self._backend._vispy_quit()\n\n    @property\n    def native(self):\n        \"\"\" The native timer on which this Timer is based.\n        \"\"\"\n        return self._backend._vispy_get_native_timer()\n\n    def _timeout(self, *args):\n        # called when the backend timer has triggered.\n        if not self.running:\n            return\n        if self.max_iterations >= 0 and self.iter_count >= self.max_iterations:\n            self.stop()\n            return\n\n        # compute dt since last event\n        now = precision_time()\n        dt = now - self._last_emit_time\n        elapsed = now - self._first_emit_time\n        self._last_emit_time = now\n\n        self.events.timeout(\n            type='timer_timeout',\n            iteration=self.iter_count,\n            elapsed=elapsed,\n            dt=dt)\n        self.iter_count += 1\n\n    def connect(self, callback):\n        \"\"\" Alias for self.events.timeout.connect() \"\"\"\n        return self.events.timeout.connect(callback)\n\n    def disconnect(self, callback=None):\n        \"\"\" Alias for self.events.timeout.disconnect() \"\"\"\n        return self.events.timeout.disconnect(callback)\n", "path": "vispy/app/timer.py"}]}