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

feature/stock-tools-update-perfo #21204

Merged
merged 14 commits into from
Jun 28, 2024
Merged

Conversation

bm64
Copy link
Member

@bm64 bm64 commented May 22, 2024

Enhance stock tools with optimized update and redraw functionality.

  • - optional benchmark

@highsoft-bot
Copy link
Collaborator

File size comparison

No differences found

@highsoft-bot
Copy link
Collaborator

Visual test results - No difference found

@highsoft-bot
Copy link
Collaborator

highsoft-bot commented May 22, 2024

Benchmark report - Stock

benchmarks/Stock/Stock-Annotations-update.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
10000 11166.38 11253.76 -87.38 -1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 11342.42 11498.07 -155.66 -1%
10000 11166.38 11253.76 -87.38 -1%

benchmarks/Stock/Stock-DataGrouping.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1040.13 1066.39 -26.26 -2%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 223.65 225.37 -1.72 -1%
10000 235.95 236.58 -0.63 0%
100000 327.96 328.96 -1 0%
1000000 1040.13 1066.39 -26.26 -2%

benchmarks/Stock/Stock-Tools-update.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
10000 3116.88 3343.36 -226.49 -7.000000000000001%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 3293.31 3556.86 -263.55 -7.000000000000001%
10000 3116.88 3343.36 -226.49 -7.000000000000001%

benchmarks/Stock/Stock-Base.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 6148.73 6162.59 -13.86 0%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 234.74 235.42 -0.69 0%
10000 323.83 324.86 -1.03 0%
100000 881.77 891.84 -10.07 -1%
1000000 6148.73 6162.59 -13.86 0%

benchmarks/Stock/Stock-Navigator-update.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
10000 5535.54 5532.37 3.17 0%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 6058.9 6067.89 -8.99 0%
10000 5535.54 5532.37 3.17 0%

benchmarks/Stock/Stock-update.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
10000 7239.09 7283.22 -44.13 -1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 6739.97 6779.15 -39.17 -1%
10000 7239.09 7283.22 -44.13 -1%

benchmarks/Stock/Stock-Ordinal.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1380.11 1392.09 -11.98 -1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 240.48 241.01 -0.53 0%
10000 261.56 258.91 2.64 1%
100000 428.97 429.64 -0.67 0%
1000000 1380.11 1392.09 -11.98 -1%

benchmarks/Stock/Stock-DataGrouping-Ordinal.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1371.64 1403.7 -32.06 -2%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 237.96 240.63 -2.67 -1%
10000 257.31 258.42 -1.11 0%
100000 433.72 432.45 1.27 0%
1000000 1371.64 1403.7 -32.06 -2%

benchmarks/Stock/Stock-Range-Selector-update.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
10000 9070.13 9108.58 -38.46 0%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 9334.31 9395.58 -61.27 -1%
10000 9070.13 9108.58 -38.46 0%

@bm64 bm64 changed the title Stock tools improved update and redraw. feature/stock-tools-update-perfo May 27, 2024
@bm64 bm64 marked this pull request as ready for review May 27, 2024 09:42
@bm64 bm64 self-assigned this May 27, 2024
Copy link
Member

@pawellysy pawellysy left a comment

Choose a reason for hiding this comment

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

Great job!
Apart from the comment below, please try fixing the failing test.
Also, could you add some tests? :)

Comment on lines 751 to 785
if (this.options.className !== this.guiClassName) {
if (this.guiClassName) {
this.wrapper.classList.remove(this.guiClassName);
}
if (this.options.className) {
this.wrapper.classList.add(this.options.className);
}
this.guiClassName = this.options.className;
}

if (this.options.toolbarClassName !== this.toolbarClassName) {
if (this.toolbarClassName) {
this.toolbar.classList.remove(this.toolbarClassName);
}
if (this.options.toolbarClassName) {
this.toolbar.classList.add(this.options.toolbarClassName);
}
this.toolbarClassName = this.options.toolbarClassName;
}

if (
!shallowArraysEqual(this.options.buttons, this.buttonList) ||
this.isDirty
) {
this.toolbar.innerHTML = AST.emptyHTML;
this.createButtons();
}

if (this.options.enabled === false) {
this.destroy();
}

if (defined(this.options.visible)) {
this.visible = this.options.visible;
}
Copy link
Member

Choose a reason for hiding this comment

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

There are a lot of if statements here. Would you mind splitting that into separate methods to improve code readability?

@bm64 bm64 requested a review from pawellysy June 5, 2024 13:19
Copy link
Member

@pawellysy pawellysy left a comment

Choose a reason for hiding this comment

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

Great work! Just one small comment.

Comment on lines 515 to 522
chart.update({
stockTools: {
gui: {
visible: !self.visible,
placed: true
}
}
});
Copy link
Member

Choose a reason for hiding this comment

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

StockTools has it's update method. Maybe we could use that to avoid some unnecessary logic?

PS: there is no placed property in the API. Should it be there?

Copy link
Contributor

@kamil-musialowski kamil-musialowski left a comment

Choose a reason for hiding this comment

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

Just a few comments, nothing major tbh. Great job overall! 👏

container.appendChild(wrapper);

this.showhideBtn = createElement('div', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it showhideBtn on purpose, or should it be showHideBtn?

@@ -144,20 +143,29 @@ function onChartAfterGetContainer(
function onChartBeforeRedraw(
this: Chart
): void {
if (this.stockTools) {
onChartRedraw.call(this);
if (this.stockTools && this.stockTools.guiEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change it to optional chaining?

Suggested change
if (this.stockTools && this.stockTools.guiEnabled) {
if (this.stockTools?.guiEnabled) {

const chart = this.chart,
guiOptions = this.options,
container = chart.container,
navigation = chart.options.navigation,
bindingsClassName = navigation && navigation.bindingsClassName;
bindingsClassName = navigation && navigation.bindingsClassName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bindingsClassName = navigation && navigation.bindingsClassName,
bindingsClassName = navigation?.bindingsClassName,

* Remove highcharts-active class from button.
* @private
*/
public removeButtonActiveClass(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid that 4fd095a removed the usage of this method, and we just have a function, but it's not used anywhere.

So we either need to remove this function, or revert the changes from the commit that removed the usage.

Copy link
Contributor

@pawelfus pawelfus left a comment

Choose a reason for hiding this comment

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

Nice! See my suggestions below

ts/Stock/StockTools/StockToolsDefaults.ts Outdated Show resolved Hide resolved
ts/Stock/StockTools/StockToolsDefaults.ts Outdated Show resolved Hide resolved
ts/Stock/StockTools/StockToolsGui.ts Outdated Show resolved Hide resolved
ts/Stock/StockTools/StockToolbar.ts Show resolved Hide resolved
ts/Stock/StockTools/StockToolbar.ts Show resolved Hide resolved
ts/Stock/StockTools/StockToolbar.ts Show resolved Hide resolved
samples/unit-tests/stock-tools/gui/demo.js Show resolved Hide resolved
ts/Stock/StockTools/StockToolbar.ts Outdated Show resolved Hide resolved
Copy link
Member

@DJTechnoo DJTechnoo left a comment

Choose a reason for hiding this comment

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

Amazing work!

Copy link
Contributor

@pawelfus pawelfus left a comment

Choose a reason for hiding this comment

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

Merge with master to get rid of failing tests. Other than that it looks good, nice! 🎉

ts/Stock/StockTools/StockToolsGui.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@kamil-musialowski kamil-musialowski left a comment

Choose a reason for hiding this comment

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

All good imo! Please verify that one little comment 👍

ts/Stock/StockTools/StockToolsDefaults.ts Outdated Show resolved Hide resolved
@bm64 bm64 requested a review from pawelfus June 25, 2024 14:27
Copy link
Contributor

@pawelfus pawelfus left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Collaborator

@TorsteinHonsi TorsteinHonsi left a comment

Choose a reason for hiding this comment

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

Thanks!

@TorsteinHonsi TorsteinHonsi merged commit bc2396a into master Jun 28, 2024
14 checks passed
@TorsteinHonsi TorsteinHonsi deleted the feature/stock-tools-update-perfo branch June 28, 2024 11:36
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.

None yet

7 participants