Performance Problems Calculated Number Fields

We have a calculation based on different custom fields to show the business value of an issue. sadly the formula is not very performant. the formula is:

<!-- @@Formula:
//Constants
var a = 0.3; // Strategical alignment (sa) and Revenue potential (rp) are weighted 30%
var b = 0.2; // Saving potential (sp) and competitive advantage (ca) are weighted 20%
var x = 2; // Is the factor for the weight of "business value" (bv) in the model
var y = 1; // Is the factor for the weight of the "loss of value" (lv) in the model
var z = 1; // Is the factor for the weight of the "capacity increase" (ci) in the model
//Variables for business value
int sa = (issue.get("customfield_11631") != null ? Integer.parseInt(issue.get("customfield_11631").toString()) : 0);
int rp = (issue.get("customfield_11632") != null ? Integer.parseInt(issue.get("customfield_11632").toString()) : 0);
int sp = (issue.get("customfield_11633") != null ? Integer.parseInt(issue.get("customfield_11633").toString()) : 0);
int ca = (issue.get("customfield_11634") != null ? Integer.parseInt(issue.get("customfield_11634").toString()) : 0);
var bv = (sa+rp)*a + (sp+ca)*b;
//Variables for loss of value over time
int lv = (issue.get("customfield_11635") != null ? Integer.parseInt(issue.get("customfield_11635").toString()) : 0);
//Variables for capacity increase
int ci = (issue.get("customfield_11636") != null ? Integer.parseInt(issue.get("customfield_11636").toString()) : 0);
//Variables for investment
int in = (issue.get("customfield_11637") != null ? Integer.parseInt(issue.get("customfield_11637").toString()) : 0);
//WSJF calculation
var wsjf = (x*bv + y* lv+ z*ci)/in;

return wsjf;

-->

we thought about converting it to something like:

<!-- @@Formula:
function q(e){return
issue.get(e)?+(issue.get(e)+""):0}return(2*((q("customfield_11631")+q("customfield_11632"))*.3+(q("customfield_11633")+q("customfield_11634"))*.2)+1*q("customfield_11635")+1*q("customfield_11636"))/q("customfield_11637");
-->

 

But then it's not working an the log is full of errors because obviously characters like the + or functions are not allowed.

Is there a solution to raise the performance or a documentation what kind of script (it's not real javascript, right?) we can try to use instead?

 

thanks in advance 

 

 

1 answer

This widget could not be displayed.

First of all, the syntax supported in Calculated Field formulas is BeanShell. It supports creating classes and methods, just like the Java language it closely resembles.

Then, how did you find out that you had performance issues? 

One very easy way to double performance would be to store the value of each field you are referencing in a variable instead of accessing it twice using issue.get(). For example:

var val = issue.get("customfield_11631");
int sa = (val != null ? Integer.parseInt(val.toString()) : 0);

Then, another cause of performance issues could be related to the fields you are accessing in the formula. What type of fields are they?

thanks for the hint with the double access by using issue.get twice. going to try that out. the fields we use are configurated as a select list (single choice) = dropdowns with numbers 1-10

This does not explain why the calculated field is so slow. How did you measure performance?

Measured it with Chrome Console - the Jira page loads fine within 1.3-1.9s but then there is a gap until Jira Agile Content is loaded and viewable around 8-9s. See Answer below with the screenshot.

I don't see the Answer below with the screenshot... Also, if you try to modify the formula to just "return 1;" , does it solve your performance issue? If not, then it means the problem does not lie with this custom field...

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

159 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you