I need some DataGrid performance help

Pi Digital sean at pidigital.co.uk
Wed May 6 06:55:19 EDT 2020


Hi Paul

What handler do you have this code? From what you are saying it seems it’s deploying this formatting script every time it redraws which itself is very inefficient and unnecessary. It should only have to deal with the data itself ideally. 

Sean Cole
Pi Digital Productions Ltd


eMail Ts & Cs


> On 5 May 2020, at 21:38, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> I have a datagid operation that should be fast that is taking a long time and I don't understand why.
> 
> I use a datagrid to display a table of data as part of an analysis. The columns are file names and the rows are selected phrases found in those files. The first column is the list of phrases (162 in this example). The remaining columns are all the file name (254 in this example). So each cell (2 to 254) represents a count of the number of times the phrase (in column 1 of the row) was found the the file that column represents.
> 
> I have the following code:
> 
>   set the dgColumnWidth[tRowColumnName]      of grp "rwMatrixObj_DataGrid" to 200
>   set the dgColumnAlignment[tRowColumnName]  of grp "rwMatrixObj_DataGrid" to "left"
>   set the dgColumnSortType[tRowColumnName]   of grp "rwMatrixObj_DataGrid" to "text"
>   set the dgColumnIsEditable[tRowColumnName] of grp "rwMatrixObj_DataGrid" to false
>   repeat with i=2 to the number of lines in tColumnNames
>     put line i of tColumnNames into tColumnName
>     set the dgColumnTooltip[tColumnName]    of grp "rwMatrixObj_DataGrid" to tColumnName
>     set the dgColumnWidth[tColumnName]      of grp "rwMatrixObj_DataGrid" to 75
>     set the dgColumnAlignment[tColumnName]  of grp "rwMatrixObj_DataGrid" to "right"
>     set the dgColumnSortType[tColumnName]   of grp "rwMatrixObj_DataGrid" to "numeric"
>     set the dgColumnSortDirection[tColumnName] of grp "rwMatrixObj_DataGrid" to "descending"
>     set the dgColumnIsEditable[tColumnName] of grp "rwMatrixObj_DataGrid" to false
>   end repeat
> 
> The first time this executes it takes just under 3 minutes for this size of data (254 columns). However, the second and each successive time in the same session it takes just under 30 minutes!
> 
> Any idea why it would take so long?
> 
> Thoughts on how to speed it up?
> 
> I realize that I could use: 'set the dgProp["column widths"] of grp <DG> to <returnDelimitedListOfWidths>' as a single set action vs a loop where I am using 'set the dgColumnWidth[tColumnName] of grp <DG> to <singleWidth>'.
> 
> However, there are only Datagid properties so set attributes for ALL columns for alignments, visibility, widths, and labels. Therefore, I have to use a loop anyway to set the tooltip, sorttype, sortdirection, end editability
> 
> The column names (in the variable tColumnNames) are file names. Some are long (longest is 113 characters) and some contain assorted punctuation. I wonder is the column NAMES should be somehting plain ASCII and short and the column LABELS contain the file names?
> 
> This is all in LiveCode 9.5.1 on Windows. Timing is approximately the same in a Standalone or the IDE.
> 
> Anyway, if anyone has a good idea of what is taking this 30 minutes, ideas would be very welcome!
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list