Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Don't use progress dialog with large data

2 REPLIES 2
Reply
Message 1 of 3
JeromeBriot
299 Views, 2 Replies

Don't use progress dialog with large data

Hello,

 

I already faced this issue with other languages so I don't call this a bug.  I just want to warn people about this behavior.

 

Here is a code that runs two empty loops:

 

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback

import time

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        elapsedTime = [0.0, 0.0]

        N = 25000

        progressDialog = ui.createProgressDialog()
        progressDialog.cancelButtonText = 'Cancel'
        progressDialog.isBackgroundTranslucent = False
        progressDialog.isCancelButtonShown = True
        progressDialog.hide()

        progressDialog.show('Speed test', 'Percentage: %p, Current Value: %v, Total steps: %m', 0, N)

        startTime = time.time()

        for i in range(0, N):

            if progressDialog.wasCancelled:
                break

            progressDialog.progressValue = i

            pass

        elapsedTime[0] = time.time() - startTime

        progressDialog.hide()

        startTime = time.time()

        for i in range(0, N):

            pass

        elapsedTime[1] = time.time() - startTime

        ui.messageBox('{:.1f} s\n{:.1f} s'.format(elapsedTime[0], elapsedTime[1]))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Now the results on my PC (i7-3700) for 25000 iterations:

  • First loop with the progress dialog: 13.2s
  • Second loop without the progress dialog: 0.0s

It's even worst on my Mac (i5-3210M):

  • First loop with the progress dialog: 208s
  • Second loop without the progress dialog: 0.0s

More results from a code in which I export mesh data to STL file with and without the progress dialog.

 

On my PC:

  • Low mesh refinement (3900 iterations): 2.0s / 0.0s
  • Normal mesh refinement (9000 iterations): 4.6s / 0.1s
  • High mesh refinement (26000 iterations): 13.1s / 0.3s
  • Very High mesh refinement (89600 iterations): 45.6s / 0.9s

Same results on my Mac:

  • Low mesh refinement (3900 iterations): 32s / 0.0s
  • Normal mesh refinement (9000 iterations): 75s / 0.1s
  • High mesh refinement (26000 iterations): 216s / 0.2s
  • Very High mesh refinement (89600 iterations): 745 / 0.8s

The progress dialog costs 0.0005 second per iteration on my PC and 0.008 second per iteration on my Mac.

 

Now you know!

 

2 REPLIES 2
Message 2 of 3
markER7TS
in reply to: JeromeBriot

Maybe you could have the best of both worlds if you modulo divide your operation count and only update the UI every few thousand loops?

Message 3 of 3

Thank you for the information.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report