Benchmarking AutoCAD object creation
with parameters from Excel.
- Author
- Summary
- Objective
- Expected finds
- Used system
- Tests
- Conclusion
- Recommendations
- Testresults
- Used VB programs
Author: Joost Beintema.
Reactions and questions to Beintema@dds.nl
Date: 09-03-2001
Summary:
For this test the AutoCAD function AddCircle was used.
This is a simple object and that would do for a first test.
Just creating a circle in AutoCAD using Visual Basic took about 0.003 seconds.
From Excel this is about 0.10 seconds.
If the coordinates and radius are fetched from an Excel sheet this changes the time for AutoCad to 0.06 seconds per circle.
For Excel this time doesn't change much and stays about 0.10 seconds.
This makes AutoCAD the preferred place to create the objects.
Objective:
Find the place to put the object-creating code for the fastest object creation in AutoCAD using parameters from Excel data sheets.
Expected finds:
- Creating objects in AutoCAD is quicker than from Excel.
This would be because of the inefficient link between Excel and AutoCAD.
There will be some kind of translation/exchange between Excel and AutoCAD which will take ectra time.
- Creating objects in AutoCAD using parameters from an Excel-sheet will be about as fast from AutoCAD as it is from Excel.
In the first case AutoCAD has to retrieve data from Excel and in the second case Excel has to send data to AutoCAD.
In both cases a translation/exchange of data has to take place.
Used system:
Computer: P166, 96Mb
OS: Windows 98
Excel: Office 97
AutoCAD: Autcad 2000
Several applications were installed on the test-machine.
While testing only Excel, Excel's VB-editor, AutoCAD and AutoCAD's VB-editor were running.
No other applications were running. No mouse or keyboard input was generated while running the tests.
This would redirect resources to the OS and therefore have influence on the results.
Tests 1:
Create circles in AutoCAD WITHOUT reading parameters from a sheet.
-Create 100 circles from Excel and AutoCad.
-Create 1000 circles from Excel and AutoCad.
-Create 10000 circles from Excel and AutoCad.
Used Excel program (important part)
Used AutoCAD program (important part)
See the results.
Tests 2:
Create circles in AutoCAD WITHOUT reading parameters from a sheet.
-Create 100, 200, 300, 400, 500 and 1000 circles from Excel.
Reason for this test is to reproduce the strange low results for 1000 circles in the irst run.
A re-run with 500 circles also resultes in a lower figure than found in the first benchmarks.
At first sight there was no difference in the setting. The test-program was the same and the running software was the same.
Since the time-difference in creating circles from Excel and AutoCAD is very clear, focussing on the exact reason in timing-differences is not interesting for the goal of this research.
See the results.
Tests 3:
Create circles in AutoCAD WITH reading parameters from the same row of a sheet .
-Create 100 circles from Excel and AutoCAD.
-Create 1000 circles from Excel and AutoCAD.
-Create 10000 circles from Excel and AutoCAD. (Not run)
Excel (partial program)
AutoCAD (partial program)
See the results.
This sheet was used:
Conclusion:
Keeping in mind the different values in the first run for the 1000 circle-run,
finding a lower figure for the 'with-sheet' variant is quite annoying but somehow not surprising.
Creating objects directly with AutoCAD is roughly 35 times faster than from Excel.
When AutoCAD has to read data from Excel this drops back to about 1.6 times faster.
Possibly either AutoCAD handles the the link to Excel better than Excel handles the link to AutoCAD or,
assuming the 'transfer rate' between the two programs is the same, less data is transmitted,
but I'm not sure where the difference comes from.
A problem I couldn't solve was 20 seconds result for creating 1000 circles I got four times.
I couldn't reproduce it, but the result is there.
Still it's faster to retrieve the data from Excel with AutoCAD.
Recommendations:
Since Excel 97 is 'old' it would be interesting to see if Excel 2000 gives better results in sending data to AutoCAD.
An other interesting thing is to find out what caused the strange '3 times faster' result.
Benchmark results:
Results 1:
| 100 circles created form... |
| Run | Excel | Acad |
| 1. | 9.890625 s | 0.322812 s |
| 2. | 9.988281 s | 0.382812 s |
| 3. | 10.097656 s | 0.320312 s |
| 4. | 10.488281 s | 0.328125 s |
| 5. | 10.488281 s | 0.328125 s |
| 6. | 9.941406 s | 0.328125 s |
| 7. | 9.890625 s | 0.390625 s |
| 8. | 9.941406 s | 0.335937 s |
| Average time per circle... |
| average | 0.100908 s | 0.003421 s |
|
| 1000 circles created form... |
| Run | Excel | Acad |
| 1. | 22.523437 s | 3.40625 s |
| 2. | 22.515625 s | 3.98438 s |
| 3. | 22.570312 s | 3.460938 s |
| 4. | 22.578125 s | 3.40625 s |
| Average time per circle... |
| average | 0.022546 s | 0.003564 s |
Sadly it wasn't possible to
reproduce these results.
|
| 10000 circles created form... |
| Run | Excel | Acad |
| 1. | 1194.844 s | 34.10156 s |
| Average time per circle... |
| average | 0.119484 s | .003410 s |
|
Results 2:
| different number of circles created form Excel |
| Circles | Time |
| 100 | 10.929687 s |
| 200 | 21.796875 s |
| 300 | 32.242187 s |
| 400 | 42.945312 s |
| 500 | 54.539062 s |
| 1000 | 108.53125 s |
| Average time per circle... |
| average | 0.108428 s |
|
| 500 circles created form Excel |
| Run | Time |
| 1. | 48.117187 s |
| 2. | 47.898437 s |
| 3. | 46.296875 s |
| 4. | 46.804687 s |
| 5. | 46.195312 s |
| 6. | 46.203125 s |
| 7. | 46.523437 s |
| 8. | 46.296875 s |
| Average time per circle... |
| average | 0.093583 s |
|
Results 3:
| 100 circles created form... |
| Run | Excel | Acad |
| 1. | 9.835937 s | 9.226562 s |
| 2. | 9.875 s | 8.070312 s |
| 3. | 9.773437 s | 6.429687 s |
| 4. | 9.671875 s | 6.15625 s |
| 5. | 9.765625 s | 6.101562 s |
| 6. | 9.890625 s | 6.148437 s |
| 7. | 9.9375 s | 6.53125 s |
| 8. | 9.84375 s | 6.085937 s |
| Average time per circle... |
| average | 0.098242 s | 0.068437 s |
|
| 1000 circles created form... |
| Run | Excel | Acad |
| 1. | 102.710937 s | 61.023437 s |
| 2. | 102.929687 s | 61.03125 s |
| 3. | 102.765625 s | 60.960937 s |
| 4. | 103.039062 s | 61.570312 s |
| Average time per circle... |
| average | 0.102861 s | 0.061146 s |
|
Used VB programs
Excel functions - direct circle creation:
The function to connect to AutoCAD is left out.
Dim objAcad As Object
Const Objects = 100
Private Sub Run_test()
Dim Loop1
Dim StartTime
Dim EndTime
Dim Result
StartTime = Timer
For Loop1 = 0 To Objects - 1
Result = CreateCircle(0, 0, 0, 100)
Next Loop1
EndTime = Timer
Result = MsgBox("Elapsed time: " & EndTime - StartTime & " seconds.", vbOKOnly)
End Sub
Private Function CreateCircle(X, Y, Z, R)
Dim objCircle As Object
Dim Center(0 To 2) As Double
Center(0) = X
Center(1) = Y
Center(2) = Z
Radius = R
Set objCircle = objAcad.ActiveDocument.ModelSpace.AddCircle(Center, Radius)
End Function
AutoCAD functions - direct circle creation:
Const Objects = 100
Private Sub Run_test()
Dim Loop1
Dim StartTime
Dim EndTime
Dim Result
StartTime = Timer
For Loop1 = 0 To Objects - 1
Result = CreateCircle(0, 0, 0, 100)
Next Loop1
EndTime = Timer
Result = MsgBox("Elapsed time: " & EndTime - StartTime & " seconds.", vbOKOnly)
End Sub
Private Function CreateCircle(X, Y, Z, R)
Dim objCircle As Object
Dim Center(0 To 2) As Double
Center(0) = X
Center(1) = Y
Center(2) = Z
Radius = R
Set objCircle = ThisDrawing.ModelSpace.AddCircle(Center, Radius)
End Function
Excel functions - circle creation from sheet:
The function to connect to AutoCAD is left out.
Dim objAcad As Object
Const Objects = 100
Private Sub Run_test()
Dim Loop1
Dim StartTime
Dim EndTime
Dim Result
StartTime = Timer
For Loop1 = 0 To Objects - 1
Result = CreateCircle(2)
Next Loop1
EndTime = Timer
Result = MsgBox("Elapsed time: " & EndTime - StartTime & " seconds.", vbOKOnly)
End Sub
Private Function CreateCircle(Row)
Dim objCircle As Object
Dim Center(0 To 2) As Double
Center(0) = ActiveSheet.Cells(Row, 1)
Center(1) = ActiveSheet.Cells(Row, 2)
Center(2) = ActiveSheet.Cells(Row, 3)
Radius = ActiveSheet.Cells(Row, 4)
Set objCircle = objAcad.ActiveDocument.ModelSpace.AddCircle(Center, Radius)
End Function
AutoCAD functions - circle creation from sheet:
The function to connect to Excel is left out.
Dim objExcel As Excel.Application
Const Objects = 100
Private Sub Run_test()
Dim Loop1
Dim StartTime
Dim EndTime
Dim Result
StartTime = Timer
For Loop1 = 0 To Objects - 1
Result = CreateCircle(2)
Next Loop1
EndTime = Timer
Result = MsgBox("Elapsed time: " & EndTime - StartTime & " seconds.", vbOKOnly)
End Sub
Private Function CreateCircle(Row)
Dim objCircle As Object
Dim Center(0 To 2) As Double
Center(0) = objExcel.ActiveSheet.Cells(Row, 1)
Center(1) = objExcel.ActiveSheet.Cells(Row, 2)
Center(2) = objExcel.ActiveSheet.Cells(Row, 3)
Radius = objExcel.ActiveSheet.Cells(Row, 4)
Set objCircle = ThisDrawing.ModelSpace.AddCircle(Center, Radius)
End Function
|