Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Evaluate() on a built field name
Message
 
 
À
17/01/2006 15:40:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
01087596
Message ID:
01087834
Vues:
16
Fabio,

Yes, tests are necessary. And if you'd taken the time to test before posting you'd have found out that a dynamic STORE command is a little (5%) to significantly faster (80%) than AddProperty().
create cursor x1 ( comment01 c(100), ;
   comment02 c(100), ;
   comment03 c(100), ;
   comment04 c(100), ;
   comment05 c(100) )
   
scatter name loData blank

insert into x1 values ( "", replicate( 'x', 30 ), replicate( 'y', 60 ), ;
   replicate( 'z', 90 ), replicate( 'a', 100 ) )

? "Test a large trim"
   
ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      store alltrim( x1.comment01 ) to ("loData.comment" + padl( m.j, 2, '0' ) )
   endfor
endfor

ltStart = seconds() - ltStart
? "store:", ltStart

ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      addproperty( loData, "comment" + padl( m.j, 2, '0' ), alltrim( x1.comment01 ) )
   endfor
endfor

ltStart = seconds() - ltStart
? "AddProperty:", ltStart


? "Test a short trim"
   
ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      store alltrim( x1.comment04 ) to ("loData.comment" + padl( m.j, 2, '0' ) )
   endfor
endfor

ltStart = seconds() - ltStart
? "store:", ltStart

ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      addproperty( loData, "comment" + padl( m.j, 2, '0' ), alltrim( x1.comment04 ) )
   endfor
endfor

ltStart = seconds() - ltStart
? "AddProperty:", ltStart

? "Test just raw store vs. addproperty()"

ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      store alltrim( x1.comment01 ) to loData.comment01
   endfor
endfor

ltStart = seconds() - ltStart
? "store:", ltStart

ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      addproperty( loData, "comment01", alltrim( x1.comment01 ) )
   endfor
endfor

ltStart = seconds() - ltStart
? "AddProperty:", ltStart

? "Test all comments to properties"
   
ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      lcName = padl( m.j, 2, '0' )
      store alltrim( evaluate( "x1.comment" + lcName ) ) to ("loData.comment" + lcName )
   endfor
endfor

ltStart = seconds() - ltStart
? "store:", ltStart

ltStart = seconds()

for i = 1 to 100000
   for j = 1 to 5
      lcName = padl( m.j, 2, '0' )
      addproperty( loData, "comment" + lcName, alltrim( evaluate( "x1.comment" + lcName ) ) )
   endfor
endfor

ltStart = seconds() - ltStart
? "AddProperty:", ltStart

? "Test just raw store vs. addproperty() for all comments"

ltStart = seconds()

for i = 1 to 100000
   store alltrim( x1.comment01 ) to loData.comment01
   store alltrim( x1.comment02 ) to loData.comment02
   store alltrim( x1.comment03 ) to loData.comment03
   store alltrim( x1.comment04 ) to loData.comment04
   store alltrim( x1.comment05 ) to loData.comment05
endfor

ltStart = seconds() - ltStart
? "store:", ltStart

ltStart = seconds()

for i = 1 to 100000
   addproperty( loData, "comment01", alltrim( x1.comment01 ) )
   addproperty( loData, "comment02", alltrim( x1.comment02 ) )
   addproperty( loData, "comment03", alltrim( x1.comment03 ) )
   addproperty( loData, "comment04", alltrim( x1.comment04 ) )
   addproperty( loData, "comment05", alltrim( x1.comment05 ) )
endfor

ltStart = seconds() - ltStart
? "AddProperty:", ltStart
>not tests are necessary, because if the VFP's C++ implementation is correct
>it is obvious that ADDPROP is more express of TO (...),
>as ADDPROP() it is a more specific command. For this reason it is also clearer.
>
>to read a variable property the correct way is : GETPEM
>
>to write a variable defined property the correct way is : ADDPROP(),
>of course, except if you want a error if the property don't exist.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform