Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pipeline profiling #57

Closed
juanmc2005 opened this issue May 20, 2022 · 3 comments
Closed

Improve pipeline profiling #57

juanmc2005 opened this issue May 20, 2022 · 3 comments
Labels
API Improvements to the API help wanted Extra attention is needed refactoring Internal design improvements that don't change the API
Milestone

Comments

@juanmc2005
Copy link
Owner

Problem

The way to calculate the real-time latency of a pipeline is currently implemented in FileAudioSource. This is counter-intuitive and has a couple of problems, like including unwanted operations in the profiling (e.g. plotting or logging).

Idea

Implement this as a wrapper over an observable in a more flexible and RxPY way.

Example

class Chronometer:
    def __init__(self):
        self.current_start_time = None
        self.history = []
    
    def start(self):
        self.current_start_time = time.monotonic()
    
    def stop(self):
        end_time = time.monotonic() - self.current_start_time
        self.current_start_time = None
        self.history.append(end_time)


def profile(observable: rx.Observable, operations: List[Operator]) -> rx.Observable:
    chronometer = Chronometer()
    return observable.pipe(
        ops.do_action(lambda _: chronometer.start()),
        *operations,
        ops.do_action(
            on_next=lambda _: chronometer.stop(),
            on_completed=lambda: print(np.mean(chronometer.history))
        )
    )
@juanmc2005 juanmc2005 added API Improvements to the API refactoring Internal design improvements that don't change the API labels May 20, 2022
@juanmc2005 juanmc2005 added this to the Version 0.4 milestone May 20, 2022
@juanmc2005 juanmc2005 added the help wanted Extra attention is needed label May 20, 2022
@RahmaYasser
Copy link

RahmaYasser commented May 28, 2022

Hello @juanmc2005 Is there a way to integrate this code with mobile app? I mean to take input from mic but in mobile app. Any hint? and thanks in advance

@juanmc2005
Copy link
Owner Author

Hi @RahmaYasser, thanks for your question. Would you mind creating a separate issue for this? Thanks!

@juanmc2005
Copy link
Owner Author

Implemented in #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Improvements to the API help wanted Extra attention is needed refactoring Internal design improvements that don't change the API
Projects
None yet
Development

No branches or pull requests

2 participants