|
-
Apr 17th, 2005, 11:14 AM
#1
Re: Why is C faster than VB
 Originally Posted by krtxmrtz
I find this quite surprising not to say hard to believe. If c is so efficient at string parsing you'd only have to take the compiled c code and convert it to assembler, on the basis that each machine instruction corresponds to an actual assembler instruction...
If you take a string parsing routine written in C, say a for loop using integer offsets to the base address of the string (array of bytes), and then decompile it to assembler, you will get about a 1-1 ratio of C code to assembler code. In other words, you may not get 1-line to 1-line correspondence, but you would not be able to reduce the assembler any further. C can be extremely close to assembler in terms of efficiency.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Apr 17th, 2005, 11:20 AM
#2
Re: Why is C faster than VB
 Originally Posted by Dave Sell
If you take a string parsing routine written in C, say a for loop using integer offsets to the base address of the string (array of bytes), and then decompile it to assembler, you will get about a 1-1 ratio of C code to assembler code. In other words, you may not get 1-line to 1-line correspondence, but you would not be able to reduce the assembler any further. C can be extremely close to assembler in terms of efficiency.
Oh I see what you mean, C is as efficient as assembler. I thought you meant assembler was less efficient than C, silly me !!!
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Apr 17th, 2005, 12:22 PM
#3
Re: Nibbles!
In many cases a C compiler will produce faster code than you will produce writing in assembly language yourself. This is beacuse the compiler knows a lot of tricks that you don't. I've actually tested it.
-
Apr 20th, 2005, 09:59 AM
#4
Re: Nibbles!
 Originally Posted by moeur
In many cases a C compiler will produce faster code than you will produce writing in assembly language yourself. This is beacuse the compiler knows a lot of tricks that you don't. I've actually tested it.
Can you post some code form both for me to test? Something no doubt memory heavy?
I've written a few things in C/C++ that are about 100-200ms quicker in ASM (32-bit: both).
Please, post something I can test..
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 20th, 2005, 10:25 AM
#5
Re: Nibbles: still need help
Can you post some code form both for me to test? Something no doubt memory heavy?
I've written a few things in C/C++ that are about 100-200ms quicker in ASM (32-bit: both).
I don't have any asm code anymore.
Make sure that when you compile the C code, you are otimizing for maximum speed and that you are not compiling the Debug code.
Of course if you know all the tricks too (like memory alignment issues) then you can produce asm code that is faster than C code since the C compiler is not 100% optimized, but I only know the obvious ones like Dave mentioned and hence produce slower code. That's why I don't use ASM anymore.
-
Apr 20th, 2005, 11:00 AM
#6
Re: Nibbles!
 Originally Posted by «°°phReAk°°»
Remember that a Megabyte, a Meg, an MB are 1048576 bytes. Most of the time though, manufacturers give specifications showing a Mebabyte is 1000000 bytes in size to let their products look 4.8576% more impressive.
Actually, this is an incorrect statement. A Megabyte is not 1048576 bytes.
See http://helios.augustana.edu/~dr/kibibytes.html.
A Megabyte is 10^6, or 1,000,000 (a million) bytes.
A Mebibyte is 2^20, or 1,048,576 bytes.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
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
|