With my scrolling VirtualView, I wanted to create a stress test for it. I didn't want to insert the stress test code into my class. So I created the Stress Class below. After my VirtualView is presented from my main, I then just create an instance if the Stress class passing it a reference to the VirtualView Class.
So all it does is scroll the view on page at a time. When it reaches the end of the scrollable content, it starts from the top of the list again.
Maybe some will think I am manic :) but I want a test like this. I will run when sleeping when my iPad is charging.
What I don't know, if I am creating some unstable conditions by calling the code like this.
I have only run with the Stress object for 15mins or so. The functionality all works fine. But I have had the editor crash a few times when after running this. I am not crashing at runtime.
I understand, this could be something with 1.6 or I could be abusing the use of ui.delay()
Any thoughts appreciated.
class Stress(object):
# an auto scroller for VirtualView class
# to stress test it.
def __init__(self, obj, delay = .1):
import console, time
# trying for saftey
ui.cancel_delays()
# no sleeping...
console.set_idle_timer_disabled(True)
self.obj = obj
self.delay = delay
# record the start time
self.start = time.time()
ui.delay(self.auto_scroll, 2)
def auto_scroll(self):
# the scrollview
sv = self.obj.sv
# current offset of the scrollview
v_offset = sv.content_offset[1]
# calc new_offset, to be + one page
new_offset = v_offset + sv.height
# wrap around if we reach the bottom if the list
if new_offset > sv.content_size[1]:
new_offset = 0
sv.content_offset = (0, new_offset )
ui.cancel_delays()
ui.delay(self.auto_scroll, self.delay)
# __del__ is not being called...
# moved the running duration code into the
# VirtualView object.
#def __del__():
#ui.cancel_delays()
#print time.time() - self.time()
