예제 #1
0
    def test_verify_and_parse_speed(self):
        dc = DataClient(host, port, storage_sender, gui_data_sender,
                        active_channels)

        dc.start_sync_verification_thread()
        dc.start_parser_thread()

        input_length = 10000
        chunk_size = 20

        with dc.expected_readings_parsed_lock:
            dc.expected_readings_parsed = input_length

        normal_bytearray_chunk = bytearray(0)
        for i in range(chunk_size):
            normal_bytearray_chunk += normal_bytearray

        start = time.time()

        for i in range(input_length / chunk_size):
            dc.fast_path_sender.send(normal_bytearray_chunk)
            with dc.frame_to_be_verified_cond:
                dc.frame_to_be_verified_cond.notify()

        with dc.parser_done_cond:
            dc.parser_done_cond.wait()

        elapsed = time.time() - start

        speed = 1 / (elapsed / input_length)

        print '\n\nParser Stage: effective frequency over %d samples is %d Hz\n' % (
            input_length, speed)
예제 #2
0
    def test_initial_sync(self):
        dc = DataClient(host, port, storage_sender, gui_data_sender,
                        active_channels)

        dc.start_sync_verification_thread()

        # play the normal_sequence twice so we get in sync
        for i in range(2):
            for x in normal_sequence:
                dc.incoming_queue.put(x)

        time.sleep(0.2)
        assert dc.synchronized