Results 1 to 29 of 29

Thread: Is VB.NET Slow

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    india
    Posts
    108

    Is VB.NET Slow

    i have PIII sytem with 256MB RAM. but my a simple application (only a form) is runnuing to slow. and in other machine also.

    the form is containing a treeview and a tab control with some textboxs...

    why?

    anand
    Anand Thakur

  2. #2
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261

    Re: Is VB.NET Slow

    Originally posted by Anand_thakur
    i have PIII sytem with 256MB RAM. but my a simple application (only a form) is runnuing to slow. and in other machine also.

    the form is containing a treeview and a tab control with some textboxs...

    why?

    anand
    VB.NET isn't slow at all (I'm currently developing a shoot'em up game with it, and I couldn't be more impressed with its efficiency. Much better than VB6).

    Could you further describe your problem? Is it just in the IDE that you're experiencing slow down? Is it just when you load the program?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    india
    Posts
    108
    after build the application...

    whenever i run my application...the forms appearance is to slow...first the form will appear then the controls appears one- by one....

    same things is happaning when i run the exe of that application.

    anand
    Anand Thakur

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Have you tried single stepping through your code (using the F8 key)?

    Sometimes applications run slow because there are control-generated events firing that you hadn't intended. Single stepping should highlight what is going on.
    This world is not my home. I'm just passing through.

  5. #5
    Lively Member
    Join Date
    Feb 2003
    Location
    UK
    Posts
    95
    I had to develop on a PIII 256Mb, and while VS.NET ran very slowly the apps I generated ran ok. Agree with the other reply, try a spot of debugging.

  6. #6
    Fanatic Member sbasak's Avatar
    Join Date
    Aug 2001
    Location
    Globe Trotter
    Posts
    524
    It's true that VB.NET is slower than VB6 because especially when running the application first time. Unlike in VB6, .NET's exe is not transformed to assembly at the beginning. Thru MSIL, it often generates native code on the fly depending on the applcation's requirement.
    Life is a one way journey, not a destination. Travel it with a smile and never regret anything.
    Yesterday is history, tomorrow is a mystery, today is gift - that's why we call it present.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB6(IDE & execution) is faster than VS.NET2002 and VS.NET2003 (as I've heard) is faster than VS.NET2002 .

  8. #8
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    Just a quick addition

    try the ngen.exe utility to generate native (not MSIL) code, might be able to squeeze a few extra miles per hour out of your app.

    PS make sure you set the complier option to BUILD and not DEBUG

  9. #9
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    There is no way VB6 is faster than .NET! I never got the speed I currently have in my games with VB6! Am I the only one to have experienced this? (Though I agree that the IDE is a bit slower in .NET)

  10. #10
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    There is no way VB6 is faster than .NET!
    i have only my experience to go on but i have to agree with the above. Differences only really show on big apps i feel . The VS7 IDE can grind a bit though, but it really is a small price to pay and i still feel it outruns JBuilder/Forte and the like

  11. #11
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    I wouldn't go so far as to say VB.NET is slow...granted it isn't as intelligent as other programming languages, but it isn't retarded either...

    Oh wait, my mistake...you meant speed wise...hehe..how embarassing...

    I develop on Win2K, PIII 850, with 256RAM...I haven't experienced any problems...are you running other applications at the same time? what about your system processes? check to see how much memory is being used when you start one of your apps.
    Last edited by Memnoch1207; May 23rd, 2003 at 03:31 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Hu Flung Dung
    There is no way VB6 is faster than .NET! I never got the speed I currently have in my games with VB6! Am I the only one to have experienced this? (Though I agree that the IDE is a bit slower in .NET)
    What's the OS you are running ? How much mem ?

  13. #13
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    Originally posted by Pirate
    What's the OS you are running ? How much mem ?
    Well, I guess I do have a better system than Anand,

    WinXP pro, P4 1.4, 256 PC-800

    But, at least on my sys, VB.NET apps are quite a bit faster than roughly equivalent VB6 apps, though i never ran any "true" benchmarks to officially test it.

  14. #14
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Hu Flung Dung
    Well, I guess I do have a better system than Anand,

    WinXP pro, P4 1.4, 256 PC-800

    But, at least on my sys, VB.NET apps are quite a bit faster than roughly equivalent VB6 apps, though i never ran any "true" benchmarks to officially test it.
    Mine is better yours

    WinXP Pro , P4 2.4 , 750 DDR , Gforce4 64DDR .

    It runs VS.NET faster than my old machine but not after I applied some ****ing SP.

  15. #15
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    VB.NET isn't slower than VB6 at all... It's only an impression. As someone else already said, the code is compiled into native code on the fly, but ONLY ONE TIME, and ONLY WHEN NEEDED. So If you have Two forms, the main form with a button (that will make the secondary form shows) and a secondary form, your application will start slowly (because the framework compiles this form). When you push your button, the first time, and only the first time, your secondary form will show slowly, because the framework compiles it, but when you close it, and push again your button the form will show immediately because the code is already compiled!

    You have a beautiful development tool, which can make programmers life easier! You can write code in COBOL, FORTRAN, Pascal, C, C++, C#.... and access ALL these object within VB.NET!!! Marvellous thing... And VB.NET is very fast! If you write a code snippet in VB and test its performance, port it to C++ (without code adjustment obviously), you'll notice no difference in speed!!!
    Learn, this is the Keyword...

  16. #16
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    I beg to differ, Xmas79. I've written functions in both VB.NET, VB6, and C++ to replace SQL comments with spaces (for parsing SQL code). The C++ version is at least an order of magnitude faster; currently I am trying to see how I can speed the VB.NET code up, but I'm not having much luck.

  17. #17
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Have you tried VS.NET 2003 ? It's much more faster than the old version . Seems a lot of bugs were fixed down .

  18. #18
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Yes, VB.NET 2003.

    If you'd like a challenge, see how fast you can write a function that replaces SQL comments with spaces. The C++ version blows the VB6 and VB.NET 2003 versions out of the water, but maybe I'm missing something.

    You have line comments (--) and block comments (/**/), but they don't affect commenting if they are inside strings (''). A "/*" after a "--" on the same line does not start a block comment. A "*/" always stops a block comment, even after a "--" on the same line.

  19. #19
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    VictorB212:
    This can be due to the precompiled routines, e.g. "strcmp(s1,s2)" can be faster (much) than the VB.NET version (dont remember the method name in the string class in this moment) (and I really don't think so, because these two functions, as they do the same thing, will be compiled in the same IL, so only one version of this function is needed).
    What I mean is if you write code, code and code, (what can you do without precompiled functions???Everything... I hope ) there's no difference.

    Another thing: did you write code in C++ (from VS6) or C++.NET? Remember the ".NET framework" is still present in VB.NET, never in C++, and it seems to me that it can be disabled putting the "unsafe" word in the function headers of the C++.NET (or this is C#? Boh...)
    Learn, this is the Keyword...

  20. #20
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    Originally posted by Xmas79
    VictorB212:
    This can be due to the precompiled routines, e.g. "strcmp(s1,s2)" can be faster (much) than the VB.NET version (dont remember the method name in the string class in this moment) (and I really don't think so, because these two functions, as they do the same thing, will be compiled in the same IL, so only one version of this function is needed).
    What I mean is if you write code, code and code, (what can you do without precompiled functions???Everything... I hope ) there's no difference.
    Actually, those vb functions aren't precompiled as you say. They just call the .NET equivalent in the String class (or StringBuilder class). Due to the extra overhead though, using strcmp would be slower (much) than calling its .NET equivalent directly!

  21. #21
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Undoubtedly, the C++ code will be faster.... it seems to me the .Net runtimes are pretty much wrappers for native code...

    For a true fair comparison though, you would have to precompile the .Net code, and use Stringbuilder and other strictly .NET functions (for instance no mid$() or Left$() )....

    In the end, the difference shouldn't be appreciable... but I would bet the C++ code would still win out, and that's ok. The point is to be able to code programs without worrying about all the crap that C++ drags with it... memory leaks... poor standardization...etc...

    Now, you could write the same function in Assembly... but when you need to make changes to how that function behaves... well, a C# project would be hella easier to update... and that's the idea...

    btw Victor, post your code... I would like to see what functions you were using...
    Last edited by nemaroller; Jun 7th, 2003 at 10:23 PM.

  22. #22
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Here's the code. It replaces what would be ANSI SQL comments with spaces.
    VB Code:
    1. Private Function DeleteComments(ByVal s As String) As String
    2.         'Replaces comments in the SQL code with spaces
    3.         'Comments consist of --comment and /*comment*/
    4.  
    5.         Dim iChar As Integer
    6.         Dim bBlockComment As Boolean
    7.         Dim bLineComment As Boolean
    8.         Dim bQuote As Boolean
    9.         Dim c() As Char
    10.         Dim cCur As Char
    11.         Dim cNext As Char
    12.  
    13.  
    14.         c = CType(s, Char())
    15.  
    16.         For iChar = 0 To c.Length - 1
    17.             cCur = c(iChar)
    18.  
    19.             If cCur = vbCr Then
    20.                 bLineComment = False
    21.  
    22.                 If bBlockComment Then
    23.                     c(iChar) = " "c
    24.                 End If
    25.             Else
    26.                 If iChar < c.Length - 1 Then
    27.                     cNext = c(iChar + 1)
    28.                 Else
    29.                     cNext = " "c
    30.                 End If
    31.  
    32.                 'if the current character is not commented out, then check to see if
    33.                 'it is the begin/end of a quote
    34.                 If Not (bLineComment OrElse bBlockComment) AndAlso cCur = "'"c Then
    35.                     bQuote = Not bQuote
    36.                 ElseIf Not bQuote Then
    37.                     'comment status can be toggled if the current character is not in a quote
    38.                     If Not (bLineComment OrElse bBlockComment) AndAlso cCur = "-"c AndAlso cNext = "-" Then
    39.                         bLineComment = True
    40.  
    41.                         c(iChar) = " "c
    42.                         iChar += 1
    43.                         c(iChar) = " "c
    44.                     ElseIf Not bLineComment AndAlso cCur = "/"c AndAlso cNext = "*"c Then
    45.                         bBlockComment = True
    46.  
    47.                         c(iChar) = " "c
    48.                         iChar += 1
    49.                         c(iChar) = " "c
    50.                     ElseIf bBlockComment AndAlso cCur = "*"c AndAlso cNext = "/"c Then
    51.                         bBlockComment = False
    52.  
    53.                         c(iChar) = " "c
    54.                         iChar += 1
    55.                         c(iChar) = " "c
    56.                     ElseIf bLineComment OrElse bBlockComment Then
    57.                         c(iChar) = " "c
    58.                     End If
    59.                 End If
    60.             End If
    61.         Next iChar
    62.  
    63.         Return CStr(c)
    64.  
    65.     End Function
    PHP Code:
    void DeleteComments(charcSrc)
    {
        
    bool bBlockComment false,
             
    bLineComment false,
             
    bQuote false;
        
    charc;


        
    // iterate through all the characters
        
    for (cSrc; *!= NULL; ++c) {
            if (*
    == '\xD') { // this character literal should start with a backslash
                // we have a carriage return
                
    bLineComment false;

                if (
    bBlockComment)
                    *
    ' ';

                continue;
            } else if (!(
    bLineComment || bBlockComment) && *== '\\'') { // this character literal should also start with a backslash
                bQuote = !bQuote;
            } else if (!bQuote) {
                if (!(bLineComment || bBlockComment) && strncmp(c, "--", 2) == 0) {
                    bLineComment = true;

                    *c = ' ';
                    ++c;
                    *c = ' ';
                } else if (!bLineComment && strncmp(c, "/*", 2) == 0) {
                    bBlockComment = true;

                    *c = ' ';
                    ++c;
                    *c = ' ';
                } else if (bBlockComment && strncmp(c, "*/", 2) == 0) {
                    bBlockComment = false;

                    *c = ' ';
                    ++c;
                    *c = ' ';
                } else if (bLineComment || bBlockComment) {
                    *c = ' ';
                }
            }
        }

    I've gotten the VB.NET code to run at about 385ms per MB; the C++ runs at about 241ms per MB.

    P.S. the VB.NET is VS 2003, and the C++ is VC6 SP5.

  23. #23
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Scratch that -- I just eliminated the last three functions I call in the C++ version and performance is up to 33ms per MB. That's almost a factor of 12 difference!
    PHP Code:
    void DeleteComments(charcSrc)
    {
        
    bool bBlockComment false,
             
    bLineComment false,
             
    bQuote false;
        
    charc,
              
    cn;


        
    // iterate through all the characters
        
    for (cSrc; *!= NULL; ++c) {
            if (*
    == '\xD') { // '[backslash]xd'
                // we have a carriage return
                
    bLineComment false;

                if (
    bBlockComment)
                    *
    ' ';

                continue;
            } else {
                
    cn = *(1);

                if (!(
    bLineComment || bBlockComment) && *== '\\'') { // '[backslash]''
                    
    bQuote = !bQuote;
                } else if (!
    bQuote) {
                    if (!(
    bLineComment || bBlockComment) && *== '-' && cn == '-') {
                        
    bLineComment true;

                        *
    ' ';
                        ++
    c;
                        *
    ' ';
                    } else if (!
    bLineComment && *== '/' && cn == '*') {
                        
    bBlockComment true;

                        *
    ' ';
                        ++
    c;
                        *
    ' ';
                    } else if (
    bBlockComment && *== '*' && cn == '/') {
                        
    bBlockComment false;

                        *
    ' ';
                        ++
    c;
                        *
    ' ';
                    } else if (
    bLineComment || bBlockComment) {
                        *
    ' ';
                    }
                }
            }
        }


  24. #24
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    VB Code:
    1. c = Ctype(s,char)
    change to
    VB Code:
    1. c = s.ToCharArray
    VB Code:
    1. ElseIf bLineComment OrElse bBlockComment Then
    2.                         c(iChar) = " "c
    3. End If
    Should be on one line .... compiler optimizes for it then.



    That should be immediately faster...

    Before we go on, are you precompiling this .Net code or just using the JIT option??
    Last edited by nemaroller; Jun 10th, 2003 at 12:04 AM.

  25. #25
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Actually, your first suggestion, to use s.ToCharArray() is a tad slower! I'm not sure how to put the ElseIf statement on one line unless I take it out of the If block it's in, and then it takes longer. I tried Return c.ToString() instead of CStr(c) and it was faster, but I need to check that the two are functionally the same.

    I am precompiling with Ctrl-F5.

  26. #26
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    VB.Net is slow. no other way to put it. even with really tiny applications consiting of basic forms and buttons, i am getting complaints.

    it just takes ages for the forms to draw and for the events to fire. i find it doesn't matter whether it's the 1st or 101st time that a form is being drawn, it still takes forever.

    is microsoft going to contiually release new versions every year forcing us to keep paying "rent" money for development environments? if so i am guessing that VS.Net 2004 will be lightening quick.....

    just my $0.02
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  27. #27
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I wholeheartedly disagree Stingrae.

    It will never be a fast as C++.... I don't know of any language besides Assembly that is...

    But from the apps I've written so far, its extremely fast.

  28. #28
    Lively Member
    Join Date
    Jul 2003
    Location
    Kuala Lumpur (Malaysia)
    Posts
    92

    I think it is almost the same.

    I think it almost the same. Because as most of the senior programmer known, the VB6 application require the VB runtime to be able it run under the windows. And also the VB.NET also require the dot net layer to execute.

    And the dotnet Framework (windows version) is depend on the windows (kernel layer) to run.

    So, as conclude. It waste a lot of processing cycle (Hz) to complete one instructions but this is to ensure it security.

    My system:
    AMD Athlon XP 2000+
    1 GB DDR

  29. #29
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    The .NET framework will be slower, but for most needs, this does not matter. The development time needed is much less than C++, possibly even less than VB6. Now, if you're coding a photo-shop-like program, C++ IS the way to go. Or a CAD suite.

    You should check that it is the CLR that is running slow and not your algorithm. If you are creating and destroying any graphics object in a loop, that's a red flag. The framework won't magically work right off -- you have to learn the intricacies of the GDI classes to really make it shine.

    You say little forms with buttons bring complaints -- that could very well happen on machines with insufficient RAM or processors in the 300 MHz range. If that is so, these people will have to upgrade to see improvement -- the whole point of .NET is that it can improve productivity at some cost of speed & memory footprint, since hardware is so cheap these days. Unless you have a huge customer base, upgrading the hardware will probably be cheaper than coding in C++.
    I have two simple requests: 1) Use useful and specific topics. 2) Modify your topic to include [Resolved] when you problem has been resolved. Both of these make the bulletin boards more useful and efficient. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width