-
Nov 27th, 2021, 07:15 PM
#1
Thread Starter
Addicted Member
[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.
-
Nov 27th, 2021, 07:44 PM
#2
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.
-
Nov 27th, 2021, 07:50 PM
#3
Thread Starter
Addicted Member
Re: Why VB.NET Power Function is so fast ?
Last edited by quickbbbb; Nov 27th, 2021 at 08:35 PM.
-
Nov 27th, 2021, 08:18 PM
#4
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
-
Nov 27th, 2021, 09:06 PM
#5
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.
-
Nov 27th, 2021, 09:13 PM
#6
Thread Starter
Addicted Member
Re: Why VB.NET Power Function is so fast ?
Originally Posted by jmcilhinney
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.
-
Nov 27th, 2021, 09:38 PM
#7
Re: Why VB.NET Power Function is so fast ?
Originally Posted by jmcilhinney
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.
Originally Posted by quickbbbb
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?
-
Nov 27th, 2021, 09:50 PM
#8
Thread Starter
Addicted Member
Re: Why VB.NET Power Function is so fast ?
Originally Posted by Niya
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
Originally Posted by Niya
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.
-
Nov 27th, 2021, 10:25 PM
#9
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
-
Nov 27th, 2021, 10:50 PM
#10
Thread Starter
Addicted Member
Re: Why VB.NET Power Function is so fast ?
Last edited by quickbbbb; Dec 1st, 2021 at 03:14 AM.
-
Nov 27th, 2021, 11:22 PM
#11
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.
-
Nov 28th, 2021, 01:10 AM
#12
Thread Starter
Addicted Member
Re: Why VB.NET Power Function is so fast ?
Originally Posted by Niya
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.
-
Nov 28th, 2021, 04:05 AM
#13
Re: Why VB.NET Power Function is so fast ?
Originally Posted by quickbbbb
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.
-
Nov 28th, 2021, 04:08 AM
#14
Re: Why VB.NET Power Function is so fast ?
Originally Posted by Niya
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.
-
Nov 28th, 2021, 05:05 AM
#15
Thread Starter
Addicted Member
Re: Why VB.NET Power Function is so fast ?
Originally Posted by jmcilhinney
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
Originally Posted by jmcilhinney
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.
-
Nov 28th, 2021, 07:10 AM
#16
Re: Why VB.NET Power Function is so fast ?
Originally Posted by jmcilhinney
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.
-
Nov 28th, 2021, 10:21 AM
#17
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
-
Nov 28th, 2021, 10:36 AM
#18
Re: [RESOLVED] Why VB.NET Power Function is so fast ?
Originally Posted by Shaggy Hiker
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.
-
Nov 28th, 2021, 11:20 AM
#19
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
-
Nov 28th, 2021, 05:03 PM
#20
Thread Starter
Addicted Member
Re: [RESOLVED] Why VB.NET Power Function is so fast ?
Last edited by quickbbbb; Dec 1st, 2021 at 03:15 AM.
-
Nov 28th, 2021, 05:07 PM
#21
Thread Starter
Addicted Member
Re: [RESOLVED] Why VB.NET Power Function is so fast ?
Originally Posted by Niya
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|