Freebasic v's C# code execution speed ?

For other topics related to the FreeBASIC project or its community.
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Freebasic v's C# code execution speed ?

Postby TESLACOIL » Jun 04, 2012 0:50

Freebasic v's C# code execution speed ? ....does anyone here have C# installed ?

Id like to know how fast the for next loops are and other simple commands like Print "hello" or line (x,y)-(x,y) are by comparison
Gonzo
Posts: 722
Joined: Dec 11, 2005 22:46

Re: Freebasic v's C# code execution speed ?

Postby Gonzo » Jun 04, 2012 11:14

perhaps you should try C# first, as it sounds like you dont know its fully OOP
which also means, no it wont be as fast in certain areas, but the programming speed will be higher
(noone measures speeds in hello world's and for loops)

c# is java, for windows

c# doesnt work on macs either...
if you want to learn a programming language, why not learn c++? or become good at FB
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Re: Freebasic v's C# code execution speed ?

Postby anonymous1337 » Jun 04, 2012 18:16

Id like to know how fast the for next loops are and other simple commands like Print "hello" or line (x,y)-(x,y) are by comparison

I hope you're kidding. Those aren't benchmark operations. If those are considered computational stress-tests for your program, I'm sure compiler optimization isn't a concern.

That being said, compiler optimization/runtime speed is one of the least important (although still important) aspects of application development.

@Gonzo:

ngen can be used to compile your program's modules to native code. It's a nice to way to cache compiled code for future use.
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: Freebasic v's C# code execution speed ?

Postby TESLACOIL » Jun 04, 2012 18:26

each command or code block will have a typical execution speed

if you want to test real world speed of a computer program written in a specific language this is one way to do it

each language will be more efficient in some respects than others, that's a given, even a simple for next loop can be very revealing as to the capabilities of the computer and the language that the for next loop is written in

dont underestimate the power of simple tests


more complex tests say on sorting, data , graphics manipulation will reveal wider trends, the simpler tests will pull up specific deficiencies
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Re: Freebasic v's C# code execution speed ?

Postby anonymous1337 » Jun 04, 2012 19:01

@Teslacoil:

You're right, although I would like to know why you want this information, because in practice, these aren't major concerns.

If (very) frequently used constructs/commands such as for-next and do-while loops, console operations, etc., were bottlenecks, someone would either fix the problem or people wouldn't use the compiler. Simple things like for-loops typically boil down to the same machine code, regardless of the language.

Functionality such as printing to the console is only as optimized as the tool used to perform this operation. Feel free to use an external library for your console operations. Not really a compiler issue.

If you want to test the "real world" speed of an application in different languages, you need to write the same application in multiple languages. That's as real as it gets.

Other than snickering at the fact that "Now I know", what would you do with this benchmark data? Choose a different compiler? Modify FBC's source code? Make some great new, super-optimized library?

I'm not saying you don't deserve the information, but if you want benchmark data so bad, why not get it yourself?
marcov
Posts: 2939
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Freebasic v's C# code execution speed ?

Postby marcov » Jun 04, 2012 19:11

To generalize Pritchards comment:

every call to a RTS function that might call the OS will possibly block the CPU for a long (OS scheduler granularity, typically 10's us) or infinite time (harddisk access, roundtrip up to hundreds of ms)

This makes benchmarking truly dependent on the workflow, rather than an abstract science.

So you want to benchmark. What exactly ? :-)
Richard
Posts: 2999
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Freebasic v's C# code execution speed ?

Postby Richard » Jun 04, 2012 20:58

The time from software concept to the execution of functional code is much longer than the time saved by variant high level language selection. The fastest language is therefore the one you can write and debug first. Any high level language can be translated once the algorithm has been tested. Writing code now is way more important than language selection. Questioning the speed of compiled code is unproductive and is really only a symptom of existential procrastination.

If FB is not fast enough then; Use assembly code to perfect the inner loop(s); Reconsider your data structure and flow; Or think outside the box and develop a more appropriate algorithm.
VonGodric
Posts: 997
Joined: May 27, 2005 9:06
Location: London
Contact:

Re: Freebasic v's C# code execution speed ?

Postby VonGodric » Jun 05, 2012 13:20

Gonzo wrote:perhaps you should try C# first, as it sounds like you dont know its fully OOP
which also means, no it wont be as fast in certain areas, but the programming speed will be higher
(noone measures speeds in hello world's and for loops)

c# is java, for windows

c# doesnt work on macs either...
if you want to learn a programming language, why not learn c++? or become good at FB
There's mono for mac and linux. SO c# and .NET do work
Gonzo
Posts: 722
Joined: Dec 11, 2005 22:46

Re: Freebasic v's C# code execution speed ?

Postby Gonzo » Jun 05, 2012 14:59

VonGodric wrote:There's mono for mac and linux. SO c# and .NET do work


i knew about mono for linux, i didnt know it works for mac too :)
thats cool
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: Freebasic v's C# code execution speed ?

Postby TESLACOIL » Jun 05, 2012 17:05

ref I would like to know why you want this information

just curious , ive been out of hard core computing for quite a while, things have changed a lot

id like to know how quick the top 10 common commands are in the top batch of languages , C# being free an obvious competitor, C and C++ fast and widely used, and perhaps Fortran as well

Ive not seen many speed tests comparisons done out there on the web

not simple honest straight forward tests like ive suggested


I did have C# installed but i forgot to write some speed test code, cant be arsed to dload and reinstall it all just to write a dozen lines of code. Its a 60 second ask to write a for loop speed test if someone already has it installed.





It would be great to have a short bit of comparator code , identical in each main language, with each section individually timed.

If you dont know the numbers then you cant gauge the differences. If such a table where constructed it would be a fascinating and insightful read.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Re: Freebasic v's C# code execution speed ?

Postby 1000101 » Jun 05, 2012 17:23

Actually there are lots of sites which compare language speeds for simple constructs. All of them are misleading given that it's not the language constructs which are the bottleneck but the algorithm used. Your first place to start optimizing for speed is to create a faster algorithm. The machine speed of the instructions used isn't the issue, it's the number of inefficient instructions and inefficient ordering because of programmer logic and algorithm methodology.

Take something which *is* speed critical such as synchronization of data between threads. There are many solutions including basic constructs such as mutexes, semaphores, critical sections and there are more complex methods such as FIFO's, queue's, read-write locks, etc.

If your program is slow, redesign your program. Porting it to another language won't improve throughput it will only increase development time. You need to do your job and let the compiler (which every you choose) do it's.
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: Freebasic v's C# code execution speed ?

Postby TESLACOIL » Jun 05, 2012 17:29

My interest is more do to with the exploration of the languages themselves rather than any immediate need for speed improvements.

How do the languages & compilers stack up ? , noting the OS environment being complex adds an extra layer.

One can then compare the theoretical efficiency with real world efficiency and see which programming language comes closest. Their strengths and weaknesses at the level of common keywords & code snippets.

First you need the raw benchmark numbers, then you can dig a little deeper.
mambazo
Posts: 652
Joined: Jul 17, 2005 13:02
Location: Ireland
Contact:

Re: Freebasic v's C# code execution speed ?

Postby mambazo » Jun 05, 2012 17:40

My interest is more do to with the exploration of the languages themselves rather than any immediate need for speed improvements.


Why title your thread "FreeBASIC vs C# code execution speed" and then claim you have no interest in execution speed?

If you have a real interest in exploring the languages, go and explore them.
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: Freebasic v's C# code execution speed ?

Postby TESLACOIL » Jun 05, 2012 17:44

Because id like to know the difference in the speed of code execution

....this is not rocket science...just a straight forward question and speedtest

ask a bunch of programmers a simple question , lol
Last edited by TESLACOIL on Jun 05, 2012 17:50, edited 2 times in total.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Re: Freebasic v's C# code execution speed ?

Postby 1000101 » Jun 05, 2012 17:49

TESLACOIL wrote:First you need the raw benchmark numbers, then you can dig a little deeper.


Actually, first you define your problem and related data associated with your problem. Next you determine your conditions and restrictions (such as hardware systems, operating systems, language choice). Then you break your problem into smaller atomic parts and design algorithms to solve those smaller parts. After that you tie it all together to solve the initial problem proposed.

The LAST thing you do is benchmark.

Finally, why would you change your story in the middle of the thread. You are obviously not "just exploring" since your question is very specific. If you were "just exploring" then benchmarking would be the furthest thing from your mind.

Can I assume from your replies that you don't have a clue?

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests