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

feat(diagnostics): Ability to load a replay of diagnostics events from file #270

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

chmeyer-ms
Copy link
Contributor

Looks like this...

diag_replay

@chmeyer-ms chmeyer-ms self-assigned this Dec 7, 2024
@chmeyer-ms chmeyer-ms requested a review from frgarc December 9, 2024 17:29
Comment on lines 57 to 62
public start() {}
public stop() {}
public pause() {}
public resume() {}
public faster() {}
public slower() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make these throw in the base so it's obvious when the wrong listener is being used? Mostly useful for future refactoring or additions

Comment on lines 43 to 49
public getName(): string {
return this._name;
}

public getUniqueId(): string {
return this._uniqueId;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields are fully static and can never change right? You could make them public readonly then to be more concise

class StatsListener {
  constructor (public readonly name: string,
    public readonly uniqueId: string) {
      this._statListeners = [];
    };
}

const stts = new StatsListener('test', 'test', []);
stts.name = 'blah'; // disallowed, will be an error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

};
}

const ReplayControls: React.FC<ReplayControlsProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React.memo this component?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same thing :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full disclosure, I have no idea what that means :). But I'd be happy to do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wrap the component you create in a call to memo

Basically caches it for each rendering of it, especially if properties don't change much.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IC... I guess I should do that to all the components then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can usually be done to a lot of components, but has a cost associated with it (caching a whole component and props comparison), but it can be a perf win. It's usually only undesirable if the properties change super often on re-render.

Comment on lines +25 to +26
private readonly MIN_SPEED = 5;
private readonly MAX_SPEED = 160;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be customizable for folks? Same with default speed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that, but slower than 5 was barely noticeable. And faster than 160 was unusable. I think fine for now.

Copy link

@frgarc frgarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
No blocking comments

Comment on lines 57 to 58
default:
break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any message error in this case?

} else if (this._simTickFreqency > this.MAX_SPEED) {
this._simTickFreqency = this.MAX_SPEED;
}
this._simTickPeriod = this.MILLIS_PER_SECOND / this._simTickFreqency;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a candidate to have its own method and avoid same code in other places, even it is one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call


const handlePluginSelection = useCallback((pluginSelectionId: string) => {
console.log(`Selected Plugin: ${pluginSelectionId}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it too noisy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly, just leftover debug message from my last PR

@chmeyer-ms chmeyer-ms merged commit 648c3d6 into main Dec 10, 2024
2 checks passed
@chmeyer-ms chmeyer-ms deleted the chmeyer/diag_replay branch December 10, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants