Skip to content

FunctionPlot: Massive performance boosts for functions with restricted domains#2158

Merged
swharden merged 6 commits intoScottPlot:mainfrom
bclehmann:perf/function-plot
Oct 7, 2022
Merged

FunctionPlot: Massive performance boosts for functions with restricted domains#2158
swharden merged 6 commits intoScottPlot:mainfrom
bclehmann:perf/function-plot

Conversation

@bclehmann
Copy link
Member

Purpose:
#2156

Most of the performance benefit comes from removing the exception-based code (that's my bad, it was my idea in the first place). XMin and XMax are just gravy, and they also are potentially useful in and of themselves, if someone only wants to consider a function on a narrow domain, this is probably an easier way to restrict that domain then manually modifying the function.

double? Normalised_Function_F(double z)
{
    return 0 <= z && z <= 1 ? z : null;
}
var f = plt.AddFunction(Normalised_Function_F);

f.XMin = 0.3;
f.XMax = 0.7;

@bclehmann
Copy link
Member Author

bclehmann commented Oct 7, 2022

I would make a benchmark, but the difference is so stark that before this PR I didn't have the patience to wait for it to render (admittedly in debug mode), and after this PR it's borderline instant

@swharden swharden linked an issue Oct 7, 2022 that may be closed by this pull request
@swharden swharden enabled auto-merge October 7, 2022 03:48
@swharden swharden merged commit 487ed7e into ScottPlot:main Oct 7, 2022
@swharden swharden mentioned this pull request Nov 6, 2022
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.

FunctionPlot: Optional X Limits

2 participants