Groups > dBase > dBase programming > Re: Datamnodref and dmd




Datamnodref and dmd

Datamnodref and dmd
Tue, 08 Apr 2008 13:30:04 -040
I sometimes use datamodref instead of a datamodule.  Part of the reason I do is
I had the impression that if formA uses a datamodref that references a dmd
MY.DMD, and if I open formB also with a datamodref that references a dmd MY.DMD,
then the tables, and thus the formB, would open more quickly if formA was
already open.  

Anyone know if that would be the case?  That is, if I use a datamodref in formA
to get to MY.DMD, and use a plain datamodule in formB for MY.DMD, would the
tables open in formB more slowly?

Thanks for any ideas on this,
Mark

Post Reply
Re: Datamnodref and dmd
Tue, 8 Apr 2008 17:49:06 -0400
In article <1I4Su4ZmIHA.1372@news-server>, NOSPAM@NOSPAM.com says...
> I sometimes use datamodref instead of a datamodule. 
> Part of the reason I do is I had the impression that
> if formA uses a datamodref that references a dmd MY.DMD,
> and if I open formB also with a datamodref that references
> a dmd MY.DMD, then the tables, and thus the formB, would
> open more quickly if formA was already open.  

I've not done tests to see if sharing a DataModRef is faster than using 
two DataModules. In the application that I've created, the only real 
slowdown that I've found is calculated fields.

On modern computers, I suspect that creating two instances of the same 
rowset is marginally slowlier than creating just one, unless the table 
is huge. To juge by yourself, try the code below.

The DataModRef exists for only one reason - to allow you to share 
datamodules between forms and between forms and reports. So use a 
DataModRef when you want to share the same instance of a DataModule with 
two or more forms (on one workstation) and use a DataModule the other 
times.

Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Blue Star dBASE Plus Core Concepts Graduate

========= Beginning of Mark.prg  =========

if not file('TestTable.dbf')
  create table TestTable (ScrambledText char(30))
  use TestTable exclusive
  generate(2000)
  use
endif

local n, c, time1, time2
time1 = seconds()
n = 0
c = new query("select * from TestTable")
c.active = false
release object c
c = null
n ++
time2 = seconds()
? "Time needed to create and destroy 1 rowset   : " +;
  (time2 - time1) + " second"
time1 = seconds()
n = 0
do
   c = new query("select * from TestTable")
   c.active = false
   release object c
   c = null
   n ++
until n = 10
time2 = seconds()
? "Time needed to create and destroy 10 rowsets : " +;
  (time2 - time1) + " second"
time1 = seconds()
n = 0
do
   c = new query("select * from TestTable")
   c.active = false
   release object c
   c = null
   n ++
until n = 100
time2 = seconds()
? "Time needed to create and destroy 100 rowsets: " +;
  (time2 - time1) + " second"

========= End of Mark.prg  =========
Post Reply
Re: Datamnodref and dmd
Wed, 09 Apr 2008 10:10:48 -040
Jean-Pierre,

Cool test.  I was surprised at just how quickly additional rowsets are created
after one exists.  I have some forms that use more than one rowset on the same
table, and was always a little concerned I was slowing down the opening of the
form.  I can see it is unlikely that would slow down the app much.

Many thanks for the demonstration.  

Mark


Jean-Pierre Martel Wrote:

> In article <1I4Su4ZmIHA.1372@news-server>, NOSPAM@NOSPAM.com says...
> > I sometimes use datamodref instead of a datamodule. 
> > Part of the reason I do is I had the impression that
> > if formA uses a datamodref that references a dmd MY.DMD,
> > and if I open formB also with a datamodref that references
> > a dmd MY.DMD, then the tables, and thus the formB, would
> > open more quickly if formA was already open.  
> 
> I've not done tests to see if sharing a DataModRef is faster than using 
> two DataModules. In the application that I've created, the only real 
> slowdown that I've found is calculated fields.
> 
> On modern computers, I suspect that creating two instances of the same 
> rowset is marginally slowlier than creating just one, unless the table 
> is huge. To juge by yourself, try the code below.
> 
> The DataModRef exists for only one reason - to allow you to share 
> datamodules between forms and between forms and reports. So use a 
> DataModRef when you want to share the same instance of a DataModule with 
> two or more forms (on one workstation) and use a DataModule the other 
> times.
> 
> Jean-Pierre Martel, editor
> The dBASE Developers Bulletin
> Blue Star dBASE Plus Core Concepts Graduate
> 
> ========= Beginning of Mark.prg  =========
> 
> if not file('TestTable.dbf')
>   create table TestTable (ScrambledText char(30))
>   use TestTable exclusive
>   generate(2000)
>   use
> endif
> 
> local n, c, time1, time2
> time1 = seconds()
> n = 0
> c = new query("select * from TestTable")
> c.active = false
> release object c
> c = null
> n ++
> time2 = seconds()
> ? "Time needed to create and destroy 1 rowset   : " +;
>   (time2 - time1) + " second"
> time1 = seconds()
> n = 0
> do
>    c = new query("select * from TestTable")
>    c.active = false
>    release object c
>    c = null
>    n ++
> until n = 10
> time2 = seconds()
> ? "Time needed to create and destroy 10 rowsets : " +;
>   (time2 - time1) + " second"
> time1 = seconds()
> n = 0
> do
>    c = new query("select * from TestTable")
>    c.active = false
>    release object c
>    c = null
>    n ++
> until n = 100
> time2 = seconds()
> ? "Time needed to create and destroy 100 rowsets: " +;
>   (time2 - time1) + " second"
> 
> ========= End of Mark.prg  =========
> 
Post Reply
Re: Datamnodref and dmd
Wed, 9 Apr 2008 20:35:32 -0400
In article <hpvVCukmIHA.1372@news-server>, NOSPAM@NOSPAM.com says...
> 
> I was surprised at just how quickly additional rowsets
> are created after one exists.

When you create a program written in dBL, once it is compiled and 
interpreted by dBASE's virtual machine, essentially it becomes a C++ 
program optimized for data manipulation. We, dBL developers, take 
advantage of 20 years of experience of dBASE.

> I have some forms that use more than one rowset on the same table,
> and was always a little concerned I was slowing down the opening
> of the form.

Making a small program like the one I've made for you, will allow you to 
see what percentage of the time needed for opening your form is caused 
by building the rowsets, connecting and filling controls with data, and 
finally rendering the form.

> I can see it is unlikely that would slow down the app much.

It will if your tables are huge or if you create calculated fields. 
Otherwise, don't worry.

Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Post Reply
about | contact