Progressive sluggishness

I have a routine that takes longer and longer to perform, the more times I perform it during the same session. It’s a routine that starts a new record, passes the new PK to a routine in another table where another new record is created. Finally the routine comes back and presents a formInDialogue.

To figure out what’s going on here, I liberally sprinkled this ```
application.output('time1 = ’ + new Date());


With that sole change the noted times from start to finish are now identical but the stall is in drawing the FID. Here's the time at the very start (time1), the time just before calling for the FID (time5a) and finally just after calling for the FID(time6).

> time1 = Mon Sep 19 2005 13:30:54 GMT-0400 (EDT)
> time5b = Mon Sep 19 2005 13:30:54 GMT-0400 (EDT)
> time6 = Mon Sep 19 2005 13:32:04 GMT-0400 (EDT)

Obviously before presenting the FID, Servoy is busy saving data. But why is it taking so long to do it? And why is it cumulative, taking longer and longer the more times the routine is invoked?

I now close the solution and re-open it, go to the same location, same data set and trigger the routine. Here's the times. 

> time1 = Mon Sep 19 2005 13:33:56 GMT-0400 (EDT)
> time5b = Mon Sep 19 2005 13:34:04 GMT-0400 (EDT)
> time6 = Mon Sep 19 2005 13:34:23 GMT-0400 (EDT)

Any ideas what's going on here?

My experience is that these things can depend on

  • how the new record is created (controller/foundset)
  • what kind of foundset you have in “hand” (how large)
  • if the foundset is shown somewhere on screen (refreshed)
  • if the foundset is cleared somtime or not

and so on.

Could you give us more code to look at? Then I think it is easier to track.

Patrick

patrick:
My experience is that these things can depend on

  • how the new record is created (controller/foundset)
  • what kind of foundset you have in “hand” (how large)
  • if the foundset is shown somewhere on screen (refreshed)
  • if the foundset is cleared somtime or not

and so on.

Could you give us more code to look at? Then I think it is easier to track.

Patrick

From the user’s point of view, they’re setting up a new piece of correspondence in the “COR” table. Behind the scenes value lists are generated for use by popups (corUtility.setupAddressing) and a new call report is created in the CR table (forms.crUtility.createCorCR).

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Method1 = corUtility.newRecordLocal()

controller.newRecord(true);
sevid = globals.gsevid;
application.output('corUtility.newRecordLocal time1a = ' + new Date());
// controller.saveData(); 
application.output('corUtility.newRecordLocal time1b = ' + new Date());
	
if ( !globals.guserid )
{
	 var title = 'corUtility.newRecordLocal';
	 var msg = 'corUtility.newRecordLocal guserid is null';
	 var btn = plugins.dialogs.showErrorDialog(title, msg);
}
else
{
	writerid = globals.guserid;
}
	
globals.gtext = '';
globals.gflag = 1;
			
finishNewRecord(); // see below for code

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Method2 = corUtility.finishNewRecord()

var cor_id = corid;
setupAddressing(); // see below for code
globals.gcurrent = corid;

forms.corNewLetterAddressing.controller.loadRecords(gcurrent$to_cor);
forms.corNewLetter.controller.loadRecords(gcurrent$to_cor);

// create matching call report
// may have been called by corLetters.onShow
application.output('corUtility.finishNewRecord time2 = ' + new Date());
if ( !crid )
{
	forms.crUtility.createCorCR(corid); // see below for code
}
application.output('corUtility.finishNewRecord time4 = ' + new Date());

crid = globals.gint2;
globals.gcrid = crid;
globals.gint2 = null;
globals.gcomid = null;
globals.gpeoid = null;
application.output('corUtility.finishNewRecord time5a = ' + new Date());
// controller.saveData();
application.output('corUtility.finishNewRecord time5b = ' + new Date());

// globals.gflag = 0; // enable close button
// forms.corNewLetterAddressing.controller.show();

globals.gflag = 1; // block close button
var title = i18n.getI18NMessage('7office.dlg.coraddress');
// not resizable, don't show text toolbar, close all on close
application.showFormInDialog(forms.corNewLetterAddressing,-1,-1,-1,-1, title, false, false, true);
application.output('corUtility.finishNewRecord time6 = ' + new Date());

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Method3 = corUtility.setupAddressing();

// sets up value lists for use in popups, shows and hides various screen elements

if ( databaseManager.hasRecords(gcomid$to_com) )
{
	if (globals.gpeoid)
	{
		forms.cpjoinUtility.controller.loadRecords(gpeoid$to_cpjoin);
	}
	else
	{
		plugins.dialogs.showErrorDialog( 'Error!', 'gpeoid error in crUtility.newRecord. Please report.' )
	}
	
	var peocount = forms.cpjoinUtility.foundset.getSize();
	forms.cpjoinUtility.setCR_Peo_VL();
	peoid = globals.gpeoid;
	
	if (globals.gcomid)
	{
		forms.cpjoinUtility.controller.loadRecords(gcomid$to_cpjoin);
	}
	else
	{
		plugins.dialogs.showErrorDialog( 'Error!', 'gcomid error in crUtility.newRecord. Please report.' )
	}
	
	var comcount = forms.cpjoinUtility.foundset.getSize();
	forms.cpjoinUtility.setCR_Com_VL();
	comid = globals.gcomid;

	var name = peoid$cor_to_peo.name_display;
	var company = comid$cor_to_com.company_name;
	globals.gutility4 = i18n.getI18NMessage('7office.fld.cor.addressee', new Array(name,company)) ;
		
	forms.corNewLetterAddressing.elements.gutility4.visible = false;
	forms.corNewLetterAddressing.elements.peo_popup.visible = true;
	forms.corNewLetterAddressing.elements.of.visible = true;
	forms.corNewLetterAddressing.elements.com_popup.visible = true;
}
else
{
	peoid = globals.gpeoid;
	globals.gutility4 = gpeoid$to_peo.first_last_name;
	forms.corNewLetterAddressing.elements.gutility4.visible = true;
	forms.corNewLetterAddressing.elements.peo_popup.visible = false;
	forms.corNewLetterAddressing.elements.of.visible = false;
	forms.corNewLetterAddressing.elements.com_popup.visible = false;
}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Method4 = forms.crUtility.createCorCR(corid)

// creates a new call report in the "CR" table.


controller.newRecord(true);
sevid = globals.gsevid;

application.output('crUtility.createCorCR time3a = ' + new Date());
// controller.saveData(); // mandatory Morley 28July2005
application.output('crUtility.createCorCR time3b = ' + new Date());
calldate = creation_date;
callerid = globals.guserid;
	
corid = arguments[0];
comid = globals.gcomid;
peoid = globals.gpeoid;
	
crsubject = i18n.getI18NMessage('7office.lbl.sec.correspondence');
	
var day = calldate.getDate();
var month = calldate.getMonth() + 1;
var year = calldate.getYear() + 1900;
	
if ( month == 1 )
{
	month = i18n.getI18NMessage('7office.month.jan')
}
if ( month == 2 )
{
	month = i18n.getI18NMessage('7office.month.feb')
}
if ( month == 3 )
{
	month = i18n.getI18NMessage('7office.month.mar')
}
if ( month == 4 )
{
	month = i18n.getI18NMessage('7office.month.april')
}
if ( month == 5 )
{
	month = i18n.getI18NMessage('7office.month.may')
}
if ( month == 6 )
{
	month = i18n.getI18NMessage('7office.month.june')
}
if ( month == 7 )
{
	month = i18n.getI18NMessage('7office.month.july')
}
if ( month == 8 )
{
	month = i18n.getI18NMessage('7office.month.aug')
}
if ( month == 9 )
{
	month = i18n.getI18NMessage('7office.month.sept')
}
if ( month == 10 )
{
	month = i18n.getI18NMessage('7office.month.oct')
}
if ( month == 11 )
{
	month = i18n.getI18NMessage('7office.month.nov')
}
if ( month == 12 )
{
	month = i18n.getI18NMessage('7office.month.dec')
}
	
crtext = 'Correspondence created ' + day + month + year + ' by ' + guserid$to_peo.name_display;
	
// to be picked up by corUtility.newRecord
globals.gint2 = crid;
globals.gcrid = crid;