After a long journey with a strange performance issue:
Polyline.IsClosed seams to be the bottle-neck.
why ?
a bug ?
do i miss something ?
UPDATE: test also for IsClosedWithinTolerance
void PolylineIsClosedPerformance(Polyline pl, int testNum = 10000)
{
Stopwatch watch = new();
//
// Rhino is Closed
//
watch.Start();
for (int i = 0; i < testNum; i++)
{
//
// SUPER SLOW - WHY ??
//
bool isClosed = pl.IsClosed;
//
//
}
watch.Stop();
Console.WriteLine($"Time taken IsClosed {testNum} times: {watch.ElapsedMilliseconds} ms");
//
// Rhino is Closed
//
watch.Start();
for (int i = 0; i < testNum; i++)
{
//
// Even slower
//
bool isClosed = pl.IsClosedWithinTolerance(1e-06); // similar results for 0.0 and 1e-06
//
//
}
watch.Stop();
Console.WriteLine($"Time taken IsClosedWithinTolerance {testNum} times: {watch.ElapsedMilliseconds} ms");
//
// compare with distance first to last
//
watch.Reset();
watch.Start();
for (int i = 0; i < testNum; i++)
{
bool isClosed = pl[0].DistanceTo(pl[pl.Count - 1]) < 1e-06;
}
watch.Stop();
Console.WriteLine($"Time taken Distance first to last {testNum} times: {watch.ElapsedMilliseconds} ms");
}
Time taken IsClosed 10000 times: 4706 ms
Time taken IsClosedWithinTolerance 10000 times: 9325 ms
Time taken Distance first to last 10000 times: 1 ms
here is the script run from the script-Editor and the 3dm with the 11158-points-polyline
Helix-Polyline-IsClosed-Test.3dm (472.0 KB)
testPolylineIsClosed_01_forum_02.cs (1.9 KB)
my system-info
(Rhino 8, Version 8 (8.26.25349.19002, 2025-12-15) on a mac intel)
systeminfo_tom_p_2026_01_07.txt (6.4 KB)
@dale - are you the right person to look at this ? or can you please add / “@” the responsible person - or tell me what s wrong. many Thanks.
kind regards, happy 2026
![]()
-tom