Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dotnetpro database performance contest
Message
De
22/06/2007 07:38:48
Markus Winhard
Lauton Software GmbH
Nürnberg, Allemagne
 
Information générale
Forum:
Visual FoxPro
Catégorie:
VFP Compiler for .NET
Divers
Thread ID:
01224231
Message ID:
01234936
Vues:
10
Hi Samuel,

after my holidays I was buried under a lot of work. So I wasn't able to come back to this thread earlier. As I saw on your web site you were also quite busy since then. :-)

Deadline for the contest is 07/07/2007 and I would really like to see the VFPCompiler for .NET participate (and win ;-) ). Is there a chance to have my code or some variation of it running till then?

I append the last version of my VFP test code for reference.

Markus Winhard
*===========================================================
* Tested with 500,000 records in Vfp5/6/7/8/9 and done in
* less than 10 seconds. :-)
* You can download test data from here:
* http://indot.net/dotnetprocontest07/testdata.zip
* or generate your own test data using
* http://indot.net/dotnetprocontest07/datagenerator.zip
* You can download VfpEncryption.fll from here:
* http://www.sweetpotatosoftware.com/files/vfpencryption.zip
*===========================================================
*--------------------------------------------
* Constants.
*--------------------------------------------
#DEFINE _TIMING_ .T.
#DEFINE _FOLDER_ "C:\Daten\"
#DEFINE _SETFIELDS_ .T.

*--------------------------------------------
* Setup.
*--------------------------------------------
#IF _TIMING_
  CLEAR ALL
  LOCAL lnSec0, lnSec1, lnSec2, lnSec3
  lnSec0 = SECONDS()
#ENDIF
SET COLLATE TO "MACHINE"
SET TALK OFF
SET NOTIFY OFF
SET NOTIFY CURSOR OFF
SET LIBRARY TO _FOLDER_ + "VfpEncryption.fll"
LOCAL lnFHandle

*--------------------------------------------
* Create a table and import CSV data.
*--------------------------------------------
ERASE _FOLDER_ + "Table*.*"
ERASE _FOLDER_ + "Adressen2.txt"
CREATE TABLE _FOLDER_ + "Table1" FREE ( ;
  Vorname C(11) NOCPTRANS, ;
  Name C(11) NOCPTRANS, ;
  Strasse C(21) NOCPTRANS, ;
  HausNr C(3) NOCPTRANS, ;
  PLZ C(7) NOCPTRANS, ;
  Ort C(18) NOCPTRANS, ;
  eMail C(38) NOCPTRANS )
APPEND FROM _FOLDER_ + "Adressen.txt" DELIMITED
REPLACE ALL ;
  Name WITH LTRIM( Name ), ;
  Strasse WITH LTRIM( Strasse ), ;
  HausNr WITH LTRIM( HausNr ), ;
  PLZ WITH LTRIM( PLZ ), ;
  Ort WITH LTRIM( Ort ), ;
  eMail WITH LTRIM( eMail )

lnSec1 = SECONDS()

*--------------------------------------------
* Copy only the unique records to a new table
* using a different table structure.
*--------------------------------------------
SET UNIQUE ON
INDEX ON Hash( Vorname + Name + Strasse + HausNr + PLZ + Ort + eMail, 5 ) TO _FOLDER_ + "Table1.idx" COMPACT
CREATE TABLE _FOLDER_ + "Table2" FREE ( ;
  Name C(22) NOCPTRANS, ;
  Strasse C(23) NOCPTRANS, ;
  Ort C(24) NOCPTRANS, ;
  eMail C(37) NOCPTRANS )
SELECT Table1
SCAN
  INSERT INTO "Table2" VALUES ( ;
    RTRIM( Table1.Vorname ) +" "+ Table1.Name, ;
    RTRIM( Table1.Strasse ) +" "+ Table1.HausNr, ;
    Table1.PLZ + Table1.Ort, ;
    Table1.eMail )
ENDSCAN
USE IN Table1

lnSec2 = SECONDS()

*--------------------------------------------
* Export to CSV. The required CSV format is
* different from VFP's default (same as the
* input file).
*--------------------------------------------
SELECT Table2
#IF _SETFIELDS_
  SET FIELDS GLOBAL
  SET FIELDS TO f1 = ;
    STUFF( RTRIM( Name ), AT( " ", Name ), 1, ", " ) +", "+ ;
    STUFF( RTRIM( Strasse ), RAT( " ", RTRIM( Strasse ) ), 1, ", " ) +", "+ ;
    LEFT( Ort , AT( " ", Ort ) - 1 ) +", "+ ALLTRIM(SUBSTR( Ort, AT( " ", Ort ) )) +", "+ ;
    RTRIM( eMail )
  COPY TO _FOLDER_ + "Adressen2.txt" SDF
#ELSE
  lnFHandle = FCREATE( _FOLDER_ + "Adressen2.txt", 0 )
  *ASSERT NOT m.lnFHandle == -1
  SCAN
    FPUTS( m.lnFHandle, ;
      STUFF( RTRIM( Name ), AT( " ", Name ), 1, ", " ) +", "+ ;
      STUFF( RTRIM( Strasse ), RAT( " ", RTRIM( Strasse ) ), 1, ", " ) +", "+ ;
      LEFT( Ort , AT( " ", Ort ) - 1 ) +", "+ ALLTRIM(SUBSTR( Ort, AT( " ", Ort ) )) +", "+ ;
      RTRIM( eMail ) )
  ENDSCAN
  FCLOSE( m.lnFHandle )
#ENDIF

*--------------------------------------------
* Done.
*--------------------------------------------
#IF _TIMING_
  lnSec3 = SECONDS()
  ACTIVATE SCREEN
  ?
  ? "overall:", m.lnSec3 - m.lnSec0
  ? "part 1 :", m.lnSec1 - m.lnSec0
  ? "part 2 :", m.lnSec2 - m.lnSec1
  ? "part 3 :", m.lnSec3 - m.lnSec2
#ENDIF
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform