Solved

How can approach VB6 code performance to that of a firstbasic exe obtained?

Posted on 2000-02-22
5
217 Views
Last Modified: 2010-05-02
I have a need to perform some calculations over a plain text ascii file.
The VB functions I use are very simple (a loop of calls to mid$ functions for each line of the file) , they should not increase performance time excesivelly.

A piece of sample code follows (not needed to follow it, is an example
of the simple operations used)

1200 OPEN nf_e$ for input as #1
1210 IF EOF(1) THEN CLOSE #1: GOTO 1380
1220 ct0_ow = 0: ct0_to = 0: ct0_no = 0: ct0_aj = 0: ct0 = 0
1230 LINE INPUT #1, RG$
1240 IF MID$(RG$, 22, 1) = "*" THEN GOTO 1210
1250 FOR k = pt1 TO ptu STEP pts
1260 IF ccew$ <> MID$(RG$, k, ctcod) THEN GOTO 1320
1270 npo = k + poso: ct0 = VAL(MID$(RG$, npo, lcam)): ct0_ow = ct0_ow + ct0
1280 npo = k + post: ct0 = VAL(MID$(RG$, npo, lcam)): ct0_to = ct0_to + ct0
1290 npo = k + posn: ct0 = VAL(MID$(RG$, npo, lcam)): ct0_no = ct0_no + ct0
1300 npo = k + posa: ct0 = VAL(MID$(RG$, npo, lcam)): ct0_aj = ct0_aj + ct0
1320 NEXT k
1330 IF caow <> ct0_ow THEN GOTO 1210
1340 IF cato <> ct0_to THEN GOTO 1210
1350 IF cano <> ct0_no THEN GOTO 1210
1360 IF caaj <> ct0_aj THEN GOTO 1210
1370 total = total + 1: GOTO 1210
....


I import the code from a Qbasic file, and with little changes it works fine with
visual basic 6.
The problem is: when I compile and generate a DOS executable with firstbasic (a Qbasic compiler) I obtain a very quick code.
I've tried to generate the same code (with all optimizations activated) to obtain a windows-VB6 executable code, and the code I obtain is -comparatively- frustrating.

It's true that the VB6 code is quicker than qbasic (interpreted),
but firstbasic code (DOS executable) is much quicker than VB6!!!

The follow timetable explains it:
For 1500 lines processed:
Qbasic code (interpreted)        VB6 executable       firstbasic code (compiled)
-----------------------------------------------------------------------------------------------
50 seconds                               16 seconds             3 seconds !!!!

I must be able to process hundreds of lines, in an interactive process, and
I'd not like to blow up my brain changing the original qbasic code to perform
akwards optimizations, since all operations are very simple (manipulation of strings and acumulation of results; little things may be optimized here)

Why is so much difference in the performance time????
How could I improve -an an easy manner- the VB code performance  ????

Any sugestion would be most appreciated

Thanks a lot !!!!
0
Comment
Question by:anmella
  • 3
5 Comments
 

Author Comment

by:anmella
ID: 2545972
Adjusted points to 75
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2546459
Well. There is no single way of doing it right. Some things you can do:

- if no user interaction is required, get rid of all the forms, and put all your code in a module. Make sure that the module at least has a sub called 'main', so that will be used to start your program.

- before you compile the program, first check the project properties from the project menu. Click on the Compile tab and play with the different optimization options.

0
 
LVL 10

Accepted Solution

by:
caraf_g earned 70 total points
ID: 2546788
"when I compile and generate a DOS executable with firstbasic (a Qbasic compiler) I obtain a very quick code."

Q1 - Does firstbasic generate a 32-bit executable?

Q2 - Do you need to do anything else in this executable

If the answer to Q1 is Yes and the answer to Q2 is No, I'd say, forget about translating it to VB and use firstbasic in this particular case.

VB runs through a run-time DLL. You'll always have a performance hit compared to something compiled into a small self-contained .exe


0
 

Author Comment

by:anmella
ID: 2549851
Well . It looks like I'll have to adapt
the whole thing the following way:

1- A permanent dos-exe program running, wich does all the processing.
It waits until a signal arises (a parameters file is created), and then it reads the parameters file, and does the processing related to those parameters, writing the results into a results file, and deleting the parameters file.

2- The vb6 program, when has the need to do the calculation, creates a parameters file, and waits until a results file is created, to read the results and display them.

It works fine for me, since the time to create and read a file are insignificant compared to those of processing.
Since, as says carafq, "VB runs through a run-time DLL. You'll always have a performance hit compared to something compiled into a small self-contained .exe " and the dos-code generated in firstbasic compiler is a 32-bit executable, it looks like the folks of Microsoft could have done things better!!!

Anyway, thanks to both of you, Mr.caraf q and p biggelaar, this time the points go to caraf q, sorry since I don't know how to share the points between both of you, but the carafq response is more accurate.
Thanks again to both of you.
0
 

Author Comment

by:anmella
ID: 2549854
Thanks again.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now