Kamila
10 months agoContributor
GetDataBuffer takes too much time to process
Dear Team,
I'm trying to understand what caused the low performance of my code. I see that it's because of many loops, but I'm wondering if there's any possible way to fix it:
Dim ResultDataBuffer As DataBuffer = New DataBuffer()
Dim sAccounts As List(Of String) = New List(Of String) From {
"1711050",
"2742020",
"1712020",
"2745060",
"1346010",
"2413010",
"1742050",
"2716050",
"1745010",
"2713010",
"3221010",
"3221020",
"3221030",
"4451010",
"4451020",
"4451030",
"1722060",
"2741030",
"4541070",
"4321020",
"4541010",
"4541020",
"3222010",
"4452010",
"4541030",
"4541040",
"4541050",
"4541060",
"5111010",
"5111020"}
Dim mICFilter As List (Of Member) = api.Members.GetBaseMembers(api.Pov.EntityDim.DimPk,api.Members.GetMemberId(dimtype.entity.Id,"Top_member"))
For Each Acc As String In sAccounts
For Each Ic As Member In mICFilter
Dim DestinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("A#" & Acc & ":O#Forms:I#" & Ic.Name & ":UD1#None:UD2#None")
'Starting data buffer
Dim StartingDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("RemoveZeros(A#" & Acc & ":O#Forms:I#" & Ic.Name & ":UD1#None:UD2#None)")
For Each sourceCell As DataBufferCell In StartingDataBuffer.DataBufferCells.Values
Dim resultCell As New DataBufferCell(sourceCell)
resultcell.SetOrigin(api,"Forms")
resultcell.SetIC(api,Ic.Name)
resultcell.SetAccount(api,Acc)
'Calculate amount and set to is NoData = true
resultcell.CellAmount = 0
resultCell.CellStatus = DataCellStatus.CreateDataCellStatus(True, False)
'Set target member
ResultDataBuffer.SetCell(si,resultcell)
Next
'Save the Data Buffer using Result Data Buffer and Destination Info
api.Data.SetDataBuffer(ResultDataBuffer,DestinationInfo)
Next
Next