Author Topic: Diagram object update performance  (Read 1806 times)

steverumsby

  • EA User
  • **
  • Posts: 27
  • Karma: +3/-0
    • View Profile
Diagram object update performance
« on: October 04, 2022, 03:34:07 am »
I have a diagram script (Javascript) that creates a heatmap by colouring diagram objects based on a tag value. This isn't a simple diagram (containing a little over 60 objects), and the script runs in just under 20 seconds. However, if I comment out the "d.Update()" line in the code so the diagram object just doesn't get updated, the runtime drops to under 5 seconds. In other words, 15 seconds of the 20 second runtime is simply processing the diagram updates.

I'm wondering if there's a trick to make this happen more quickly? Can they be batched so they all happen at once? It is quite nice, maybe even hypnotic(!),  to see the elements changing colour one at a time but I'd happily give that up if I could make it all happen faster. Any suggestions?

This is EA 16.05 connecting via PCS 1.05 to an MSSQL DB. The connection to PCS is via a VPN (when I'm at home and not in the office) and that does affect the runtime somewhat. The times would all be much shorter with a proper wired network to the server, but I'm an home much of the time so VPN it is...

Thanks,
Steve.

qwerty

  • EA Guru
  • *****
  • Posts: 13525
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: Diagram object update performance
« Reply #1 on: October 04, 2022, 04:44:38 am »
You don't need to update the diagram object if you just alter the diagramObjects! Update the diagram object only if you alter its properties (like name, flags, etc.).

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8551
  • Karma: +254/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Diagram object update performance
« Reply #2 on: October 04, 2022, 09:30:01 am »
Hi Steve,

We normally create Heatmaps with a dynamic Legend based on the Tag value.  Is there a reason why you didn't take that approach?  That seems to be quicker, we've had maps of over hundreds of items that don't seem overly slow.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

steverumsby

  • EA User
  • **
  • Posts: 27
  • Karma: +3/-0
    • View Profile
Re: Diagram object update performance
« Reply #3 on: October 06, 2022, 08:15:21 pm »
You don't need to update the diagram object if you just alter the diagramObjects! Update the diagram object only if you alter its properties (like name, flags, etc.).

q.

Not sure what you mean. If I don't call d.Update() on the diagram object after the script changes its background colour, the displayed diagram doesn't change. Am I completely misunderstanding something? Always possible - I'm fairly new to Sparx EA!

Steve.

qwerty

  • EA Guru
  • *****
  • Posts: 13525
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: Diagram object update performance
« Reply #4 on: October 06, 2022, 08:17:51 pm »
Probably. You likely only want a Reload of the diagram, rather than an update. (Always hard to tell without seeing a source.)

q.

steverumsby

  • EA User
  • **
  • Posts: 27
  • Karma: +3/-0
    • View Profile
Re: Diagram object update performance
« Reply #5 on: October 06, 2022, 08:23:09 pm »
Hi Steve,

We normally create Heatmaps with a dynamic Legend based on the Tag value.  Is there a reason why you didn't take that approach?  That seems to be quicker, we've had maps of over hundreds of items that don't seem overly slow.

HTH,
Paolo

The colouring in this particular heatmap is not based directly on the tag value but on a calculation using the tag value. Specifically the tag value is a date (when maintenance ends for this element) and the colouring is based on the relationship of that date to today - red for in the past, orange for in the next 12 months, etc. So I don't think a dynamic legend would work for this.

I suppose I could store the result of that calculation in another tag and build a dynamic legend from that. That might work better. Hmmm.... Thanks for the idea!

Steve.

steverumsby

  • EA User
  • **
  • Posts: 27
  • Karma: +3/-0
    • View Profile
Re: Diagram object update performance
« Reply #6 on: October 06, 2022, 08:39:10 pm »
Probably. You likely only want a Reload of the diagram, rather than an update. (Always hard to tell without seeing a source.)

q.

The source is a little complicated, but is effectively something like this:
Code: [Select]
for(d in diagramobjects) {
    var c = calculateAColour(diagramobjects[d])

    diagramobjects[d].BackgroundColor = c
    diagramobjects[d].Update()
}
If I call the "Update()" method the scrips takes a lot longer. If I don't, the visible diagram doesn't change. If I add a call to "Repository.ReloadDiagram(diagramID)" the visible diagram still doesn't update. If I manually reload the diagram after the script has finished, it still doesn't change. It seems like I really need the "Update()" call?

Steve.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12996
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram object update performance
« Reply #7 on: October 06, 2022, 08:45:43 pm »
Yes, you definitely need the diagramObject.Update statement.

You don't need a Diagram.Update() statement is what q. suggested.

But as suggested by Paolo, it might be interesting to look into the diagramLegends for coloring the elements on a diagram.
That is a standard mechanism provided by EA.

If the calculation of the color is too complex, you could have your script calculate the color value, and use that in the legend.

Geert

steverumsby

  • EA User
  • **
  • Posts: 27
  • Karma: +3/-0
    • View Profile
Re: Diagram object update performance
« Reply #8 on: October 06, 2022, 08:55:09 pm »
Yes, you definitely need the diagramObject.Update statement.

You don't need a Diagram.Update() statement is what q. suggested.

I misunderstood. Sorry! In fact I don't have a Diagram.Update() so by accident has discovered I don't need it  :D

Yes, it looks like storing the colour value (or at least a simple value that will determine the colour) and then using that in a legend is the way to go.

Thanks all. Advice much appreciated.

Steve.
« Last Edit: October 07, 2022, 01:14:07 am by steverumsby »