Solved

VB5 runs twice slower then VB3. Why?

Posted on 1997-06-17
12
358 Views
Last Modified: 2008-03-10
A Project was originally developed in Visual Basic 3.0
Now I am trying to upgrade it to VB 5.0. Beside user iterface it contains some calculations
( mostly with dates ( in string format like "12:34pm" ) manipulations )
which can last from several seconds to several minutes.
After conversion to VB 5 I realised that code ( bottleneck procedure ) runs 110% slower
( even in 32bit compiled version ) in comparison
with exactly the same code running in VB3 (p-code )version.
Tested code contains some calls to VB Run-Time Library
Functions ( DateAdd, Format ).
Even after two day of code optimisation for VB 5.0 I couldn't archive better result.

Please, can you try to explain me what is the reason of VB5 to be slower then VB3 and if possible your recomendations to make it faster
0
Comment
Question by:cyberdudesergei
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 1

Expert Comment

by:Amberite
ID: 1427371
As also experienced with VB4, VB5 is a much more complex development environment than VB3. VB3 was a 5-10 megabyte program while VB5 is 120+. VB5 has all new code routines for 32 bit windows development, in adition to using many more DLLs. Also, VB5 has different, "3D" controls while VB3 has "Flat" controls, and finally, programs written from VB3 were designed to be run under win3.1, while code written under VB5 is primarily designed for Win95 development; this adds to alot of extra DLLs, etc. There is nothing to do about performance problems; VB5 will be slower than VB4, and VB4 will be slower than VB3, etc. BUT, have you tried making the EXE, and then running the EXE, instead of in VB5? Compiling it and running straight from the EXE should speed things up, since its not in the VB5 development environment anymore.
0
 

Author Comment

by:cyberdudesergei
ID: 1427372
The point is that at this case it was measured execution time spent in one procedure( Same code for VB5 and VB3 ). The procedure contains simple code ( no user interface, no ActiveX, DLL calls ) with several calls to VB Run-Time Lib Functions. For VB5 compiled ( not p-code ) EXE was tested.
May be the problem that in VB5 ( since VB3 ) internal presentation of VB String object was changed and now all string comparision and equation operations are slower??
0
 
LVL 1

Expert Comment

by:Amberite
ID: 1427373
In my answer I mentioned this point, which I guess you disregarded. *VB5 APPLICATIONS USE DIFFERENT DLL'S TO RUN (MSVBVM50.DLL, ETC) TO RUN APPLICATIONS. THESE DLLS ARE WIN95 DLL'S AS OPPOSED TO VB3'S DLLS, WHICH ARE WIN3.1. JUST LIKE WIN3.1 IS 100 TIMES FASTER THAN WIN95, SO IS VB3 IS 100 TIMES FASTER THAN VB5. GET IT???*
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1427374
What kind of machine did you run these tests on? I assume that you have a test program to run? Could you post a copy of it, I would like to test it on my system. I run WinNT, so there really should be a great advantage for the 32-bit version, and it would be interesting to see if the outcome is different here.

E-mail: y96andha@cyd.liu.se
0
 
LVL 1

Expert Comment

by:Amberite
ID: 1427375
damn you y96, do you hunt around for me? :)
0
 

Author Comment

by:cyberdudesergei
ID: 1427376
To Amberite:The tested code ( procedure in the project ) contains just several calls to VB Run-time library functions ( Format, DateAdd ) which probably reside in 32 bit DLL. Functions of 32bit DLL should be faster then the same function of 16bit DLL ( because of non-segmented, flat memory model and more advanced set of CPU instructions ), if it is simple machine code which does't contain any calls to OpSystem API and other DLLs.
Have you heard something about internal representation of VB String Object and how it was changed from VB3 to VB5? In Win95 String in the UniCode format was introduced. In unicode string each character takes 16 bit instead of 8bit in normal C string.
I agree that Win95 generally is fatter and slower then Win3.1, but not in this specific case of procedure which should be complied to simple set of machine intruction.

To y96andha: It is a good idea to try to run in on WinNT, but still most of the clients will be using this application on Win95. Sorry I cannot separate tested procedure - it it part of the project.

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Expert Comment

by:Amberite
ID: 1427377
Look, cyberdud, it doesnt matter if you have NO code in your projects, EXE's written in VB5 still require MSVBVM50.DLL in order to run, and uses this dll to show the window on the screen, etc. Now, the code in the DLL is what is slowing it down, because the code in the DLL is all 32 bit, instead of 16 bit with Win3.1. This is also why VB4 32 bit applications ran slower than the same VB4 16 bit application. Its the matter of 32 bit over 16 bit. Thats why it is slower.
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1427378
To Amberite: No, Amberite, I just look at all questions asked and see if there is anything I'd like to say or ask. What did you think of my University?

To cyberdudesergei: Could you post the tested procedure anyway, so I could make a test program using the same number of instructions, and same type of instructions that you've used?
0
 

Author Comment

by:cyberdudesergei
ID: 1427379
The following is some code to test speed of string concatenation
in VB3 and VB5. Test shows that VB5 is about 80% slower.
Why - VB5 works with strings stored internally in UNICODE format.
In Visual C++ 5.0 there is  an option "#define _UNICODE" if you want it ON, but unflexible VB doesn't have it and use UNICODE by default.
Test code:
VERSION 2.00
Begin Form Form1
   Caption         =   "Form1"
   ClientHeight    =   1815
   ClientLeft      =   3000
   ClientTop       =   1605
   ClientWidth     =   3600
   Height          =   2220
   Left            =   2940
   LinkTopic       =   "Form1"
   ScaleHeight     =   1815
   ScaleWidth      =   3600
   Top             =   1260
   Width           =   3720
   Begin CommandButton Command1
      Caption         =   "Press To Test"
      Height          =   495
      Left            =   1140
      TabIndex        =   0
      Top             =   510
      Width           =   1395
   End
   Begin Label Result
      Alignment       =   2  'Center
      Caption         =   "Result Time"
      Height          =   285
      Left            =   660
      TabIndex        =   1
      Top             =   1170
      Width           =   2385
   End
End
Option Explicit

Sub Command1_Click ()
    Dim tmStartTime  As Variant
    Dim strTemp As String
    Dim iSpentTime, iIndex1, iIndex2 As Integer
    Form1!Result.Caption = "Wait please - calculating"
    tmStartTime = Now
    For iIndex1 = 1 To 10000
        strTemp = ""
        For iIndex2 = 1 To 100
            strTemp = strTemp + " test" 'Str$(Int(10000 * Rnd))
        Next iIndex2
    Next iIndex1
    iSpentTime = DateDiff("s", tmStartTime, Now)
    Form1!Result.Caption = "Time Spent " + Str$(iSpentTime) + " Sec"
End Sub


0
 

Accepted Solution

by:
bjarnej earned 100 total points
ID: 1427380
VB3 functions where mostely implemented as assembly, whereas VB4-VB5 is implemented as C(++) functions, to ease development of Vbscript, so that they could use the same code in all applications and on all platforms.

I haven't experimented with VB5 myself but filling large arrays in VB4 is 100% slower than i VB3.

And 32 bit applications is normally not faster than 16 Bit aplications : they are larger, the flat model only gives benefit when handling large amount of data, compilers are stupid they are not able to use the many fance instructions in 32 bit.

The only place 32 bit gives increase speed is in number crunshing applications.

VB5 is slower than VB3 because Microsoft decided that portability was more important than speed.
0
 
LVL 7

Expert Comment

by:kamall
ID: 1427381
Dear cyberdudesergei, dear friends

I think that you are discussing for nothing !!!
Everybody have to know that Windows 95 and NT are much more slower than Win3.1, no matter what VB is being used (or which compiler or EXE). I tried both VB3 and VB4 on Win 3.11, 95, and NT, and at last VB5 on Win 95. The performance was grealtly degraded on all 32-bit platforms in all aspects.
I finally understood that the best solution ever is to develope my application in Win 3.11 with VB3.
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1427382
The problem with developing applications in Win3.11 with VB3 is that you get lots of compatibilty problems when users try to use your programs in 95 or NT, and that you retain the old memory problems of Win 3.11.
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

Suggested Solutions

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

14 Experts available now in Live!

Get 1:1 Help Now