<commit_before># License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

# test:device L500*
# test:device D400*

import pyrealsense2 as rs
from rspy.stopwatch import Stopwatch
from rspy import test
import time
import platform

# Start depth + color streams and measure the time from stream opened until first frame arrived.
# Verify that the time do not exceeds the maximum time allowed
open_call_stopwatch = Stopwatch()

# Function will wait for the first frame for 'max_delay_allowed' + 1 extra second
# If the frame arrive it will return the time it took since open() call
# If no frame it will return 'max_delay_allowed'
def time_to_first_frame(sensor, profile, max_delay_allowed):
    first_frame_time = max_delay_allowed

    def frame_cb(frame):
        nonlocal first_frame_time
        if first_frame_time == max_delay_allowed:
            global open_call_stopwatch
            first_frame_time = open_call_stopwatch.get_elapsed()

    open_call_stopwatch.reset()
    sensor.open(profile)
    sensor.start(frame_cb)

    # Wait condition:
    # 1. first frame did not arrive yet
    # 2. timeout of 'max_delay_allowed' + 1 extra second reached.
    while first_frame_time == max_delay_allowed and open_call_stopwatch.get_elapsed() < max_delay_allowed + 1:
        time.sleep(0.05)

    sensor.stop()
    sensor.close()

    return first_frame_time


dev = test.find_first_device_or_exit()

max_delay_for_depth_frame = 5
max_delay_for_color_frame = 5

# Set maximum delay for first frame according to product line
if dev.supports(rs.camera_info.product_line):
    product_line = dev.get_info(rs.camera_info.product_line)
    if product_line == "D400":
        max_delay_for_depth_frame = 1.5
        max_delay_for_color_frame = 1.5
    elif product_line == "L500":
        max_delay_for_depth_frame = 2.5 # depth frame has a 1.5 seconds built in delay at the FW side + 1.0 second for LRS
        max_delay_for_color_frame = 1.5

ds = dev.first_depth_sensor()
cs = dev.first_color_sensor()

dp = next(p for p in<commit_msg>CR fixes II<commit_after># License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

# test:device L500*
# test:device D400*

import pyrealsense2 as rs
from rspy.stopwatch import Stopwatch
from rspy import test
import time
import platform

# Start depth + color streams and measure the time from stream opened until first frame arrived.
# Verify that the time do not exceeds the maximum time allowed
# Note - Using Windows Media Foundation to handle power management between USB actions take time (~27 ms)
open_call_stopwatch = Stopwatch()

# Function will wait for the first frame for 'max_delay_allowed' + 1 extra second
# If the frame arrive it will return the time it took since open() call
# If no frame it will return 'max_delay_allowed'
def time_to_first_frame(sensor, profile, max_delay_allowed):
    first_frame_time = max_delay_allowed

    def frame_cb(frame):
        nonlocal first_frame_time
        if first_frame_time == max_delay_allowed:
            global open_call_stopwatch
            first_frame_time = open_call_stopwatch.get_elapsed()

    open_call_stopwatch.reset()
    sensor.open(profile)
    sensor.start(frame_cb)

    # Wait condition:
    # 1. first frame did not arrive yet
    # 2. timeout of 'max_delay_allowed' + 1 extra second reached.
    while first_frame_time == max_delay_allowed and open_call_stopwatch.get_elapsed() < max_delay_allowed + 1:
        time.sleep(0.05)

    sensor.stop()
    sensor.close()

    return first_frame_time


dev = test.find_first_device_or_exit()
time.sleep(3) # The device starts at D0 (Operational) state, allow time for it to get into idle state
max_delay_for_depth_frame = 5
max_delay_for_color_frame = 5

# Set maximum delay for first frame according to product line
if dev.supports(rs.camera_info.product_line):
    product_line = dev.get_info(rs.camera_info.product_line)
    if product_line == "D400":
        max_delay_for_depth_frame = 1.5
        max_delay_for_color_frame = 1.5
    elif product_line == "L500":
        max_delay_for_depth_frame = 2.5 # depth frame has a 1.5 seconds built in delay at the FW side + 1.0 second for LRS
        max_delay_for_color_frame = 1.5

ds = dev.first_depth_sensor()
cs = dev.first_color_sensor()

dp = next(p for p in
{'fraction_non_alphanumeric': 0.06692465285681766, 'fraction_numerical': 0.01957659913498748, 'mean_word_length': 3.8606194690265485, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6432690', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1344, 'n_words': 448}