Performance measurementsΒΆ

This notebook tries to push a number of frames to the browser as fast as posisble, using different parameters, and measures how fast it goes.

[ ]:
import time
import numpy as np
from jupyter_rfb import RemoteFrameBuffer

class PerformanceTester(RemoteFrameBuffer):
    i = 0
    n = 0

    def get_frame(self):
        if self.i >= self.n:
            return None
        array = np.zeros((640, 480), np.uint8)
        # array = np.random.uniform(0, 255, (640, 480)).astype(np.uint8)
        array[:20,: int(array.shape[1] * (self.i + 1) / self.n)] = 255
        self.i += 1
        self.request_draw()  # keep going
        return array

    def run(self, n=100):
        self.i = 0
        self.n = n
        self.request_draw()

w = PerformanceTester(css_height='100px')
[ ]:
w
[ ]:
n = 50
w.max_buffered_frames = 2
w.reset_stats()
w.run(n)
[ ]:
# Call this when it's done
w.get_stats()
[ ]: