Make PlottableSignalConst generic#100
Conversation
|
Hi @StendProg, thank you for working on this! This pull request improves However, this change also makes At first I thought we could keep I'm looking forward to hearing what you think! Thanks again for your excellent work. |
|
I also really do not like reduce speed of signal.I think its not posible to make non generic base class for Signal and SignalConst, because he must hold source array, that generic type for SignalConst. |
This sounds like a good plan to me! Thank you @StendProg! |
|
This line is crashing the audio monitor demo |
|
My bad. Fixed this. |
|
Looks great, thanks again @StendProg! |
|
You can make cookbook demo with 1 Billion points of 'byte', it need only 3 GB memory for data. |
|
A bit late idea. In generic PlottableSignal check type for double and call fast not LinqExp implementation of min/max search. and LinqExp for other. That will stay speed for double[] at same level as before, and allow other types at reduced speed. |
Suggested by @StendProg in #100
|
I looks like it rendered in simple min/max implementation. Please check x64 mode, and trees ready flag. It can be rendered for 10-20 ms too. After long data generation and trees calculations |
Oops, that's what I did wrong.
Haha it is a bit late but I like the idea. I'm less familiar with LinqExp and generics though, so I'd probably have to look at a PR to really understand it. I think for now it's in a good place though: If you are plotting a live double array use PlottableSignal. If you are plotting fixed data or data of another type, use PlottableSignalConst. That should probably cover most of the use cases.
|
|
What is your code to make that plot? Mine seems to keep going slow... byte[] oneBillionPoints = ScottPlot.DataGen.SinSweepByte(1_000_000_000, 8);
var plt = new ScottPlot.Plot(width, height);
plt.Title("Display One Billion points with PlotSignalConst()");
plt.Benchmark();
plt.Parallel(false);
plt.PlotSignalConst(oneBillionPoints, sampleRate: 20_000_000);
plt.SaveFig(fileName); |
|
Copy pasted yours. but i make it in gui app. Double check x64 mode. x86 dont allow more then 2-3 GB total ram for process. |
That did the trick, thanks! |
Simple overload works: public PlottableSignalConst<T> PlotSignal<T>(
T[] ys,
double sampleRate = 1,
double xOffset = 0,
double yOffset = 0,
Color? color = null,
double lineWidth = 1,
double markerSize = 5,
string label = null
) where T : struct, IComparable
{
if (color == null)
color = settings.GetNextColor();
PlottableSignalConst<T> signal = new PlottableSignalConst<T>(
ys: ys,
sampleRate: sampleRate,
xOffset: xOffset,
yOffset: yOffset,
color: (Color)color,
lineWidth: lineWidth,
markerSize: markerSize,
label: label,
useParallel: settings.useParallel
);
settings.plottables.Add(signal);
return signal;
} You can implement this, if you like. |
|
Thanks for this code! I started a bigger issue to track conversion of all plot types to generics (#103) |
Make PlottableSignalConst generic
Suggested by @StendProg in ScottPlot#100


Signal and SignalConst maked generic, thats allow plot different types of struct data types (float, int, byte etc). This types must be convertable to Double.
With generic data types all comparation calculation goes slower by 30-40%.
SignalConst overall render not visibly affected by this.
PlottableSignal Render slower by 10-20% for 10M points at high resolution chart. Posible improvement commented in MinMaxRangeQuery(), but it will give lots of code duplicates for all posible data types.