Hi! So, I tested the following code:
int X = 100;
using (var psd = new PsdImage(300, 100))
{
for (var i = 0; i < X; i++)
{
var watch = Stopwatch.StartNew();
psd.AddTextLayer($"text {i}", new Rectangle(0, 0, 10, 10));
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);
}
var saveWatch = Stopwatch.StartNew();
psd.Save("myLoopingTest.psd", new PsdOptions());
saveWatch.Stop();
Console.WriteLine($"save: {saveWatch.ElapsedMilliseconds}");
}
and noticed it takes longer for each iteration to execute AddTextLayer, starting arround 700ms and ending about 3s (per AddTextLayer invocation).
I ran some tests… executed the same code for 20, 40, 60, 80 & 100:
image.png (53.1 KB)
Almost the exact same times, each iteration takes longer to execute than the one before.
I also found out, when invoking the Save method takes a lot of time too, for bigger numbers, it takes more that what it took to add every layer.
image.png (16.0 KB)
So, my question is: is there any way to improve these times?
My typical PSD (mostly text, with some images and figures) is taking 6 minutes each, almost all of it because of the TextLayers.
Thanks.