Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing VB performance against VFP
Message
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00583110
Message ID:
00585779
Vues:
26
I just came across the following REALLY USEFUL tip on InStep technologies' website. It won't always apply, but I think that for Claudio's case, it might work!

---------------------------------------------------------------
FROM http://www.insteptech.com/VBLang.htm
---------------------------------------------------------------
Why is my string handling so slow?
Visual Basic Version: All

Issue: My application is performing poorly. When I evaluated where the problems were, I found it to be in the string handling. Why is my string handling so slow and what can I do about it?

The following tidbit of information is from the new book: "VB Developer's Guide to ASP and IIS" (Sybex) by Russell Jones. "...VB must allocate memory and create a new string every time you concatenate two strings together. The longer the two strings are, the more memory (and time) it takes to concatenate them. By using shorter strings or byte arrays, you can often dramatically speed up a routine with very little work."

Another tip from Jones, if you need to concatenate many different string elements into a large string you can get better performance by building each string individually and concatenating all of them at the same time.

Another option is to use the MID$ function. This would work as follows:

' Prepare the length of the string
' This is critical for performance reasons
sLargeString = Space$(rs.RecordCount * 52)
lPos = 1

' Copy each field from the recordset to a UDT
' and append this all to a very long string
Do Until rs.EOF
udtTeamDetail.TeamID = rs!TeamID
udtTeamDetail.TeamName = rs!TeamName & ""
udtTeamDetail.TeamGames = Val(rs!TeamGames & "")
udtTeamDetail.TeamWins = Val(rs!TeamWins & "")

LSet udtTeamSummary = udtTeamDetail
Mid$(sLargeString, lPos, 52) = udtTeamSummary.TeamBuffer
lPos = lPos + lUDT

rs.MoveNext
Loop

---------------------------------------------------------------
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform