|
-
Jul 4th, 2002, 05:26 PM
#1
Thread Starter
Lively Member
C++ vs VB and C#
ive made a test of speed between VB and VC++:
VB Code:
for i=0 to 786432 ' (1024x768)
buffer(i)=Color
next i
runs at 15.81 FPS
empty loop runs at 23.5 FPS
on VC++ the same code runs at 232.3 FPS
and 320.3 FPS for the empty for.
can someone post here the results of C# on this test?
use QueryPerformanceFrequency() and QueryPerformanceCounter() to count the FPS.
the testing executable should be executed from outside the IDE (it might slow it down and change the real result)
-
Jul 4th, 2002, 08:12 PM
#2
Hyperactive Member
with virtual pascal:
runs 20 fps.
empty loop 100 fps.
Better than VB, but just only.
-
Jul 5th, 2002, 05:31 AM
#3
Thread Starter
Lively Member
thanks for adding your language to the comparison, i should have said it before, every language is welcome.
please post here more tests
(by the way, i know of pascal and delphi, whats virtual pascal?)
-
Jul 5th, 2002, 06:25 AM
#4
Comparing the speed of languages is only usefull when done on the same machine, so I don't think what you are trying to achieve here makes much sence,
best regards
Sascha
-
Jul 5th, 2002, 06:33 AM
#5
Thread Starter
Lively Member
you got a point there ;-)
ive thought of it myself just before ive read youre post (when ive replied on the Game and Graphic forum)
please program the exe on a certain lang and post the EXE here by the name of the language, i'll run it on my comp so we could compare it.
-
Jul 5th, 2002, 09:29 AM
#6
Hyperactive Member
Instructions are important, please read.
Just run both of these, and it will output a number. divide it by 5. That's how many milliseconds iit takes, so for FPS, divide 1000 into it(example below). The faster one is obviously the empty one. PS: The only difference between virtual and normal, is, well, the people who named the compiler No difference
FPS=1000/(MILLISECONDS/5)
so an output of 50 would be 100 FPS!
-
Jul 5th, 2002, 12:24 PM
#7
Thread Starter
Lively Member
recoded my program:
Code:
//VARs
const arrSize = 1024*768;
DWORD bBuffer[arrSize];
char str[20];
_int64 iFreq,iStart,iEnd, sum;
_int32 i,j;
//program:
QueryPerformanceFrequency((LARGE_INTEGER *)&iFreq);
iFreq/=1000;
if (iFreq) {
QueryPerformanceCounter((LARGE_INTEGER *)&iStart);
iStart/=iFreq;
sum=0;
for(j=0;j<100;++j) {
for(i=0;i<arrSize;++i) {
bBuffer[i]=12421;
}
QueryPerformanceCounter((LARGE_INTEGER *)&iEnd);
iEnd/=iFreq;
sum=iEnd-iStart;
}
MessageBox(NULL,_i64toa(100000/((sum)/(iFreq/1000)),str,10),"Title",MB_OK | MB_ICONINFORMATION);
}
else MessageBox(NULL,"Error!, no timer","Error!!!",MB_OK);
the results on my comp were:
356.09FPS avarage
highest score is 380FPS
lowest score is 321FPS
using Delphi PsychoMark made an EXE which when i ran scored:
250.58FPS avarage
231FPS lowest
270FPS highest
please program in your favorite language and send me the EXE so i could write your score here.
we'll soon have a compare table of the speeds of all languages used around this forum
youre welcome to suggest any other tests and include some code and EXE so i'll compare them
-
Jul 5th, 2002, 12:39 PM
#8
Thread Starter
Lively Member
ok, my code wasnt counting FPS... i didnt think when i coded this... ;-)
replcaed with:
Code:
for(i=0;i<arrSize;++i) {
bBuffer[i]=12421;
}
QueryPerformanceCounter((LARGE_INTEGER *)&iEnd);
iEnd/=iFreq;
sum=sum+(iEnd-iStart);
}
MessageBox(NULL,_i64toa(1000/sum,str,10),"Title",MB_OK | MB_ICONINFORMATION);
now it makes more sence ;-)
and Delphi is the winner!
i got only 150FPS avarage....
although my first code got better result - i mean the one without the new mistakes, ive screwed around with it and now i cant get my old code to work fast anymore 
compilers are wierd... i'll look into my assembly code later to see whats wrong if i'll have enough time (and when i'll be calm which wont likely will last enough time for me to realise whats wrong ;-))
i know you cant judge just by that simple test, but if i'll see Delphi is faster, i'll RUN to it ;-)
-
Jul 5th, 2002, 02:30 PM
#9
Hyperactive Member
Instructions are important, please read.
Just run both of these, and it will output a number. divide it by 5. That's how many milliseconds iit takes, so for FPS, divide 1000 into it(example below). The faster one is obviously the empty one. PS: The only difference between virtual and normal, is, well, the people who named the compiler No difference
FPS=1000/(MILLISECONDS/5)
so an output of 50 would be 100 FPS!
Note: The loop with code in it got messed up in the compression or something, so I can only post the empty one.sorry
Last edited by snakeeyes1000; Jul 5th, 2002 at 02:47 PM.
-
Jul 5th, 2002, 03:21 PM
#10
Thread Starter
Lively Member
i got only one number on the screen, it was 20...
so if its not 2 and 0 (which will be too damn fast)
its 250 FPS, thats close to what Delphi scored for the loop with the asignment. my VC++ was faster, but now im stuck with 160FPS...
i have no idea whats wrong, its the same code....
-
Jul 6th, 2002, 08:31 PM
#11
And l bet if you knocked up some assembly code it would run the test even faster
-
Jul 13th, 2002, 08:55 AM
#12
Hyperactive Member
short comment: the loops in vc++ and c# should be nearly equal
-
Jul 13th, 2002, 08:58 AM
#13
Thread Starter
Lively Member
please create an exe with it so i could test it on my comp then
-
Jul 13th, 2002, 09:13 AM
#14
Hyperactive Member
ok - this sample is very basic
1. see the code and try it
2. run the same code in vc++
3. see the results
-
Jul 13th, 2002, 09:35 AM
#15
Thread Starter
Lively Member
what exactly the massage: ### loops per sec says, is it how many times the loop for i=1 to 786432 ran with assigning a int32 array some value?
if the loop does that, and you can run it the number of times per sec it says you can (which i seriously doubt)
the C# is even faster the assembly ;-)
it says it does 566116 loops per sec, whice is 200 times faster then any language....
i think you got a major calc error there
-
Jul 13th, 2002, 09:38 AM
#16
Hyperactive Member
I didn't say that this is for i = 1 to 786432
this shows how many for loops the program is able to
run through in 1 second
for(int i = 0; i >= 0; i++)
...
this means there is no end of the loop
it only breaks after one second in my code and
shows you the count of i
there's no loop limitation of 786432
-
Jul 13th, 2002, 09:40 AM
#17
Hyperactive Member
btw: this is only a loop check and has nothing to do with any screen resolution
-
Jul 13th, 2002, 09:46 AM
#18
Hyperactive Member
ok - I just found an error in that app:
I used the Application.DoEvents() method that is
not usefull at this part of the code and dramatically
slows the code.
I removed the line and the loopcount should be much
more higher than before.
try it again.
-
Jul 13th, 2002, 10:00 AM
#19
Thread Starter
Lively Member
when i convert it to the for loop the other testing programs work with (the res 1024x768) so i could change it to FPS, C# is above VB with 35.551 FPS, but way below C and Delphi
-
Jul 13th, 2002, 10:06 AM
#20
Hyperactive Member
35 FPS?
I think that must be suboptimal code because even when you
run several directx loops that contain of some rendering
procedures, I get about 72 frames per second and this is in
3D mode (1024 x 768)
so i guess if you don't use that rendering thing, it must be possible to get much more frames.
-
Jul 13th, 2002, 10:08 AM
#21
Hyperactive Member
i recommend to write the same code I gavve you in vc++
and see how many loops it has done after 1 second.
if it is much more, than vc++ would be more efficient...
let's have a try
-
Jul 13th, 2002, 10:59 AM
#22
Thread Starter
Lively Member
i recommand that you create a program whice runs a loop of 1 to 786432 and modifies an array of int[786432] and calculate the FPS like all the other tests we did, i'll build a program that does what yours did too, so we can compare the two results
(it might take me more then a day since i need to fix my computer)
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
|