# Can I make this faster - Parallel

• ### Question

• ```                        Dim skPoints As New List(Of SketchPoint)
Dim skPointsCache As New List(Of Point)
For Each sl As SketchLine In skLines
sl.Construction = True
Dim booDuplicate As Boolean = False
Dim startPoint As Point = sl.StartSketchPoint.Geometry3d
Dim endPoint As Point = sl.EndSketchPoint.Geometry3d
For i As Integer = skPointsCache.Count - 1 To 0 Step -1
Dim skp As Point = skPointsCache(i)
If Distance(skp, startPoint) < 0.0625 Then
booDuplicate = True
Exit For
End If
Next
If booDuplicate = False Then
End If
booDuplicate = False
For i As Integer = skPointsCache.Count - 1 To 0 Step -1
Dim skp As Point = skPointsCache(i)
If Distance(skp, endPoint) < 0.0625 Then
booDuplicate = True
Exit For
End If
Next
If booDuplicate = False Then
End If
Next```

I have a loop for lines (2 points = 1 line) that compares start/endpoints on a junk distance (< 1/16 unit), then adds the unique points to a list.  Each loop is taking over 1000ms(still!).  I am looking for ways to speed things up, because it shouldn't take this long.  Time is lost using the Inventor API to get the points (approx. 30-60ms), so I cached them, and used my own distance formula (approx. 7ms) to get the distance between 3d points.  Overall that didn't really help.

Can anybody see a pattern where I can use some parallel computing to get a unique list of points?

Thanks,

jvj

Friday, May 25, 2018 8:17 PM

• I guess it can be made faster:

```Dim skPoints As New List(Of SketchPoint)
Dim skPointsCache As New List(Of Point)
Sub(sl)
Dim booDuplicate As Boolean = False
Dim startPoint As Point = sl.StartSketchPoint.Geometry3d
Dim endPoint As Point = sl.EndSketchPoint.Geometry3d
For i As Integer = skPointsCache.Count - 1 To 0 Step -1
Dim skp As Point = skPointsCache(i)
If Distance(skp, startPoint) < 0.0625 Then
booDuplicate = True
Exit For
End If
Next
If booDuplicate = False Then
SyncLock skPoints
End SyncLock
SyncLock skPointsCache
End SyncLock
End If
booDuplicate = False
For i As Integer = skPointsCache.Count - 1 To 0 Step -1
Dim skp As Point = skPointsCache(i)
If Distance(skp, endPoint) < 0.0625 Then
booDuplicate = True
Exit For
End If
Next
If booDuplicate = False Then
SyncLock skPoints