VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
Go Back  Xtreme Visual Basic Talk > > > VB6 v Gnu Compiler Collection


Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2016, 12:15 AM
Mathimagics's Avatar
MathimagicsVB6 v Gnu Compiler Collection Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,152
Unhappy VB6 v Gnu Compiler Collection


One particular problem with VB6 is that the compiler remains in its 1998 form, languishing, neglected by MS, while others move on.

Consider the following benchmark test results (all times in seconds):
Code:
                           **      VB        PB      F90       C    
   18 Hard      4.092    1257     1.089    0.643    0.183    0.162  
   18 Harder    4.324   10461     6.769    4.132    1.248    1.205
   24 Hard      4.077   70745    20.951   13.954    4.974    4.622
   24 Harder    4.235   91274    41.762   26.015    8.656    8.300
   24 XHard     4.130  290853   266.735  157.172   50.839   49.154
   24 Killer    4.267 2229694  1123.824  700.226  247.378  229.261
The application is a simple Kakuro puzzle solver. It uses a standard DFS approach, and the column headed ** indicates the number of recursions used (ie. search tree node count). It uses two arrays, a 2D array for grid state, and a 3D array for cell domains (which values are allowed in each cell).

I ported this to PowerBasic (PB), F90 and C. No tricks were used, no pointers, a "conventional" port in all cases. All report the same number of recursions in each case. Note that my PB compiler is almost as old as VB6, so it's a "legacy" case as well.

The VB6 app was compiled with maximum optimisations (ie no runtime checks). The F and C apps were compiled with GCC 5.30 gfortran and c, with max (-O3) optimisation settings.

There was a time when I would have bet on VB and PB being just as fast as C for this type of app, and in fact the F and C versions, when compiled without optimisations, do run in times more comparable to VB6/PB. It's the GCC -O3 option that make for the dramatic performance boost.

These time comparisons are so great that I will probably wind up making a DLL version of the C port, and calling that from the master VB project whence it came.
__________________
Cogito, ergo codo
Reply With Quote
  #2  
Old 09-16-2016, 03:27 PM
Cerian Knight's Avatar
Cerian KnightVB6 v Gnu Compiler Collection Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,169
Default

I've seen that level of performance delta show itself in VB6 when 'On Error Resume Next' exists anywhere within a maths sub/function. The severe performance penalty is not negated by a subsequent 'On Error Goto 0'.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 09-18-2016, 06:37 PM
dilettante's Avatar
dilettanteVB6 v Gnu Compiler Collection dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,517
Default

Some of the difference is probably due to newer and improved compiler optimization, some due to code generation for newer Intel architectures, and some due to programming language "metaphores." VB6 and VC6 most likely default to code for 386 generation hardware, though VC6 offers better access to switches targeting later hardware.

I suppose it is possible that you might get C2.EXE to accept some of the VC6 switches. Either by wedging VB6's Make process or using the undocumented .VBP section [VBCompiler].

Example I have seen:

Code:
[VBCompiler]
LinkSwitches=/BASE:0x77170000 /DLL /ENTRY:DllMain /EXPORT:GetECC /OPT:NOWIN98
Supposedly there is a key "C2Switches" you can use as well. See:

VBStreets - Native DLL - VB6

Ideally though we'd need a newer C2.EXE code generator and I doubt one was ever produced. I'm not sure what it might take to wrap a later VC C2.DLL as a C2.EXE to be run by VB6.EXE, but maybe none of them accept the intermediate VB6 code anyway.

Last edited by dilettante; 09-18-2016 at 06:47 PM.
Reply With Quote
  #4  
Old 09-19-2016, 05:53 PM
Cerian Knight's Avatar
Cerian KnightVB6 v Gnu Compiler Collection Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,169
Default

When discussing 2D and 3D arrays, there might be additional benefit in taking advantage of the simultaneous add/multiply and/or index pre-calculation, by converting to 1D arrays (under a narrow set of circumstances):
Code:
'All compile optimizations enabled
Option Explicit
Dim Arr(99, 99, 99) As Long
Dim Arr2(999999) As Long

'3D array test
Private Sub Command1_Click()
Dim I As Long
Dim X As Long, Y As Long, Z As Long
Dim T1 As Single, T2 As Single
T1 = Timer
For I = 1 To 1000
    For X = 0 To 99
        For Y = 0 To 99
            For Z = 0 To 99
                Arr(X, Y, Z) = I
            Next
        Next
    Next
Next
T2 = Timer
MsgBox T2 - T1
End Sub

'1D array test
Private Sub Command2_Click()
Dim I As Long, J As Long, K As Long
Dim X As Long, Y As Long, Z As Long
Dim T1 As Single, T2 As Single
T1 = Timer
For I = 1 To 1000
    For X = 0 To 99
        J = X * 10000
        For Y = 0 To 99
            K = Y * 100 + J
            For Z = 0 To 99
                Arr2(K + Z) = I
            Next
        Next
    Next
Next
T2 = Timer
MsgBox T2 - T1 '> 3x faster on circa 2007 Xeon 2.8GHz
End Sub
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #5  
Old 09-22-2016, 11:08 PM
dilettante's Avatar
dilettanteVB6 v Gnu Compiler Collection dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,517
Default

I find the PB timings to be the most puzzling. It shouldn't have the handicaps that VB6 does, since it got worked on for many years after VB6 had been cast in stone.

It almost seems like it is targeting the same vintage of Intel hardware but with less bounds checking and other fluffy code around operations. I'm not sure all of those can be turned off via VB6 optimizations since some are baked into VB6 Runtime and OLE calls, and of course PB may emit inline code instead of making some of the calls.
Reply With Quote
Reply

Tags
vb6, compiler, compiled, optimisations, recursions, time, gcc, array, harder, port, app, cell, f90, times, hard, checks, apps, runtime, remains, maximum, settings, gnu, optimisation, collection, gfortran


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
 
VB6 v Gnu Compiler Collection
VB6 v Gnu Compiler Collection
 
-->