Results 1 to 21 of 21

Thread: [RESOLVED] Why VB.NET Power Function is so fast ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Resolved [RESOLVED] Why VB.NET Power Function is so fast ?

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
           Dim w As Long
           Dim s As Single
           Dim v As Double
           Dim tt As Single
           tt = Microsoft.VisualBasic.Timer
           v = 1.234
           
           For w = 1 To 10000000
              s = v ^ 0.333333!
              
           Next
          MsgBox(Str$(Microsoft.VisualBasic.Timer - tt))
        End Sub
    VB.NET = 0.6 second
    VB6_EXE = 1.17 second ( native code )
    delphi = 0.72 second
    freebasic = 0.94 second

    How To let vb6 power ^ be more fast ??
    Last edited by quickbbbb; Nov 27th, 2021 at 08:37 PM.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,043

    Re: Why VB.NET Power Function is so fast ?

    VB6 by default in the IDE uses a bytecode virtual machine which executes instructions slower than native code. VB.Net on the other hand always executes native code. Did you perform the VB6 test after a native code compilation?

    However, I'll look into this myself and see what I come up with.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: Why VB.NET Power Function is so fast ?

    ...........
    Last edited by quickbbbb; Nov 27th, 2021 at 08:35 PM.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,924

    Re: Why VB.NET Power Function is so fast ?

    VB6 is old. It may be that the optimal way to perform a power function was different back then than it is now because of different functionality that has been added to the chip. Something as fundamental as the power function might have been optimized to compile one way that was best back then, but is no longer best.

    Just speculation, though.
    My usual boring signature: Nothing

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,905

    Re: Why VB.NET Power Function is so fast ?

    Your title says:
    Why VB.NET Power Function is so fast ?
    Is that really the question you want answered? In your post you ask this:
    How To let vb6 power ^ be more fast ??
    Which is a completely different question and something that should be asked in the VB6 forum, not the VB.NET forum. Decidce what it is that you actually are asking and ask it in the appropriate place. If you have two separate questions, especially if they are about two separate languages, then ask them in two separate threads.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by jmcilhinney View Post
    Your title says:

    Is that really the question you want answered? In your post you ask this:

    Which is a completely different question and something that should be asked in the VB6 forum, not the VB.NET forum. Decidce what it is that you actually are asking and ask it in the appropriate place. If you have two separate questions, especially if they are about two separate languages, then ask them in two separate threads.

    NO

    ( First )
    example: I can use Net Compile Power Function to Standard DLL , and let vb6 call the dll

    I had try use Net Com.DLL ( Niya provide here ) but it will be more slow ( 1.5 second )

    so only use Standard DLL can let vb6 has a fast power function

    ( Second )

    many people proficient VB.NET at the same time proficient VB6
    Last edited by quickbbbb; Nov 27th, 2021 at 09:27 PM.

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,043

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by jmcilhinney View Post
    Which is a completely different question and something that should be asked in the VB6 forum, not the VB.NET forum.
    Actually I think questions like this belongs in the VB.Net section. Many VB.Net programmers were also VB6 and VBA programmers, but not the other way around. I think we all know how the VB6 people feel about .Net around here. A question like this requires knowledge of both VB6 and .Net to answer and you're more likely to find that here on the .Net side than the VB6 side.

    Quote Originally Posted by quickbbbb View Post
    NO

    ( First )
    example: I can use Net Compile Power Function to Standard DLL , and let vb6 call the dll

    I had try use Net Com.DLL ( Niya provide here ) but it will be more slow ( 1.5 second )

    so only use Standard DLL can let vb6 has a fast power function

    ( Second )

    many people proficient VB.NET at the same time proficient VB6
    What kind of DLL did you make?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by Niya View Post
    What kind of DLL did you make?
    (1) I use your Net to Activex DLL Sample to build a power function , but when vb6 use it , vb6 become more slower
    (2) I use delphi or freebasic to build standard dll , and when vb6 use it , vb6 become more faster

    but the most faster power function is VB.NET not delphi

    so I hope find a way to build standard dll by VB.NET

    Quote Originally Posted by Niya View Post
    A question like this requires knowledge of both VB6 and .Net to answer and you're more likely to find that here on the .Net side than the VB6 side.
    so it is not improper that I think my question post in VB.NET
    Last edited by quickbbbb; Nov 27th, 2021 at 09:58 PM.

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,924

    Re: Why VB.NET Power Function is so fast ?

    I'm curious as to why it matters? I certainly care about things like this, but I'm well aware that it doesn't matter for anything I happen to be doing. So, I'm curious as to what you have found where this can make a difference?
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: Why VB.NET Power Function is so fast ?

    ......
    Last edited by quickbbbb; Dec 1st, 2021 at 03:14 AM.

  11. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,043

    Re: Why VB.NET Power Function is so fast ?

    If that is the case, did you test your calculation with a C++ version to see how fast it is? If you want to a simple function export that is usable from VB6, C++ has the best compiler for this. It is very trivial to export a function from a C++ program.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by Niya View Post
    If that is the case, did you test your calculation with a C++ version to see how fast it is? If you want to a simple function export that is usable from VB6, C++ has the best compiler for this. It is very trivial to export a function from a C++ program.

    I am successful

    I use VC2015 to get the speed as same as VB.NET

    thank you

    ===========
    VB.NET Activex.DLL = 1.5 second
    VB.NET = 0.6 second
    VC++ = 0.6 second
    VB6_EXE = 1.17 second ( native code )
    delphi = 0.72 second
    freebasic = 0.94 second
    powerbasic = 1.34 second
    Last edited by quickbbbb; Nov 28th, 2021 at 08:09 AM.

  13. #13
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,905

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by quickbbbb View Post
    many people proficient VB.NET at the same time proficient VB6
    So what? Should we just do away with the VB6 forum and have all VB6 questions poste3d in the VB.NET forum because "many people proficient VB.NET at the same time proficient VB6"? There is a place for VB6 questions for a reason.

  14. #14
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,905

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by Niya View Post
    Actually I think questions like this belongs in the VB.Net section. Many VB.Net programmers were also VB6 and VBA programmers, but not the other way around. I think we all know how the VB6 people feel about .Net around here. A question like this requires knowledge of both VB6 and .Net to answer and you're more likely to find that here on the .Net side than the VB6 side.
    Except not. Why a VB.NET method is as fast as it is is a 100% VB.NET question. How to make a VB6 function faster is a 100% VB6 question. Two different questions on two different languages, both of which have a dedicated forum. How VB6 developers feel about VB.NET is irrelevant if you just ask the VB6 question in the VB6 forum without polluting it with unrelated VB.NET questions and vice versa.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by jmcilhinney View Post
    Except not. Why a VB.NET method is as fast as it is is a 100% VB.NET question. How to make a VB6 function faster is a 100% VB6 question. Two different questions on two different languages, both of which have a dedicated forum. How VB6 developers feel about VB.NET is irrelevant if you just ask the VB6 question in the VB6 forum without polluting it with unrelated VB.NET questions and vice versa.

    (1)

    I ask how to use VB.NET Compile a Standard DLL or Activex DLL , so it is related VB.NET

    https://www.vbforums.com/showthread....le-code-as-DLL

    The post is the second post , I trying to ask other people to get a methode of VB.NET compile a Standard DLL

    In the beginning , I did not mention
    but later . I mention

    Quote Originally Posted by jmcilhinney View Post
    So what? Should we just do away with the VB6 forum and have all VB6 questions poste3d in the VB.NET forum because "many people proficient VB.NET at the same time proficient VB6"? There is a place for VB6 questions for a reason.

    (2)

    My ask questions in past , 50 topics only 3 or 4 topics in VB.NET
    If I do not know what is the right time to post in VB.NET or VB6 forum , my 50 topics will be all post in VB.NET forums


    my first ask for VB.NET is: How to bind pointer to array + why VB.NET Array lbound can not as 1
    my second ask for VB.NET is: How to use VB.Net compile a dll
    my third ask for VB.NET is: why VB.Net power can be so fast

    only because include how to let VB6 more fast in third post , Can make you so unhappy ????
    may be has someone know how to compile a standard dll and let vb6 use it !
    Last edited by quickbbbb; Nov 28th, 2021 at 08:48 AM.

  16. #16
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,043

    Re: Why VB.NET Power Function is so fast ?

    Quote Originally Posted by jmcilhinney View Post
    Except not. Why a VB.NET method is as fast as it is is a 100% VB.NET question. How to make a VB6 function faster is a 100% VB6 question. Two different questions on two different languages, both of which have a dedicated forum. How VB6 developers feel about VB.NET is irrelevant if you just ask the VB6 question in the VB6 forum without polluting it with unrelated VB.NET questions and vice versa.
    The question he asked is why was the VB.Net version faster than the VB6 version. Answering this question would require someone to know how both compilers work. The guys in the VB6 section hate .Net with a passion which means they don't use it hence there is a high chance they would not know anything about it's inner workings. VB.Net programmers on the other hand more often that not would also have a background in VB6 which means there is a chance they would know both environments. So when someone asks a question that involves any comparison between the two such as the OP asked here, chances are they would find the answer on this side.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  17. #17
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,924

    Re: [RESOLVED] Why VB.NET Power Function is so fast ?

    When you have calculation (or any algorithm) that takes THAT long, you have opportunities to consider some radical algorithmic changes, which are likely to have far greater impacts than just tweaking one calculation. Of course, those also tend to be specific to the program in question, so there isn't much that could be said in general, but here are two items that you may or may not have thought about:

    1) If it is a calculation that is either repeated lots of times (such as in a loop), or has parts that can be separated out and calculated out of order from the rest, then threading could double or triple your speed.

    2) Back before the Pentium, floating point math, including the trigonometry functions, was so slow that it couldn't be used in games. So, at that time, lookup tables would be created at startup. These lookup tables could be arrays of values that would be, for example, the Sin of all degrees from 1 through 360. That would mean that a trig function would become nothing more than an array lookup, and would therefore go from painfully slow to super fast. Is there some kind of pre-calculation, or caching, that would work for your equation such that you don't repeat slow parts? After all, memory is cheap, CPU time is dear.
    My usual boring signature: Nothing

  18. #18
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,043

    Re: [RESOLVED] Why VB.NET Power Function is so fast ?

    Quote Originally Posted by Shaggy Hiker View Post
    1) If it is a calculation that is either repeated lots of times (such as in a loop), or has parts that can be separated out and calculated out of order from the rest, then threading could double or triple your speed.
    I'd go lower level than that in addition to multi-threading. I'd start considering SIMD. Both C++ and VB.Net have ways of utilizing SIMD instruction sets. The performance benefits here could be enormous. If that still not enough, he could look into things like CUDA which allows you to utilize your GPU to perform parallel calculations.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,924

    Re: [RESOLVED] Why VB.NET Power Function is so fast ?

    It all falls into the same general category: Optimizing code performance can gain you seconds, optimizing algorithms can gain you minutes.
    My usual boring signature: Nothing

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: [RESOLVED] Why VB.NET Power Function is so fast ?

    ........
    Last edited by quickbbbb; Dec 1st, 2021 at 03:15 AM.

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    196

    Re: [RESOLVED] Why VB.NET Power Function is so fast ?

    Quote Originally Posted by Niya View Post
    I'd go lower level than that in addition to multi-threading. I'd start considering SIMD. Both C++ and VB.Net have ways of utilizing SIMD instruction sets. The performance benefits here could be enormous. If that still not enough, he could look into things like CUDA which allows you to utilize your GPU to perform parallel calculations.
    I has ever thought about GPU
    Last edited by quickbbbb; Nov 28th, 2021 at 05:17 PM.

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