[C] swapping vars
Moderator: MaxCoderz Staff
I agree that readibility is important, but I don't really bother going through time.h or what have you, so I would rather it be insanely optimized rather than even somewhat readible. Then again, I've only really used high-level langauges like C++ and I don't know how often asm is used in the industry today. Still, in the case of Wiki's definition, I think that it should be in its most readible form, which it currently is. I assume King's optimization is based off of it somehow anyways. Thats my two cents.
I suspect at most one or two people find this thread constructive now as it came to a dead end on the first page. Shelling out advice on how to go from here is the most constructive thing I can think of and I could only think of one thing to say... Sorry if my advice insulted you, but your lack of understanding what has been said in this thread can be insulting too
I also fail to see why not a single person has minded the little hints in every one of my posts as to why this thread is pointless.
Alright, this is definitely my last post in here
I also fail to see why not a single person has minded the little hints in every one of my posts as to why this thread is pointless.
Alright, this is definitely my last post in here
-
- MCF Legend
- Posts: 1601
- Joined: Mon 20 Dec, 2004 8:45 am
- Location: Budapest, Absurdistan
- Contact:
But you will be going through at least your own old code quite often. You can’t expect yourself to remember how it works after a few weeks.crzyrbl wrote:I agree that readibility is important, but I don't really bother going through time.h or what have you, so I would rather it be insanely optimized rather than even somewhat readible.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
comments?But you will be going through at least your own old code quite often. You can’t expect yourself to remember how it works after a few weeks.
well if you look at it like that, every discussion is pointless because no one is going to change his or her opinion anyway, except kids whom you can still tell anything and they'll believe it.I also fail to see why not a single person has minded the little hints in every one of my posts as to why this thread is pointless.
sure, but I understand it alright, I don't have to agree with it. I certainly see that some/most ppl aren't going to bother optimizing at a low lvl, but that's their problem, imo they should take the time to do that - if available.Sorry if my advice insulted you, but your lack of understanding what has been said in this thread can be insulting too
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Buy that can... You're saying very devious things. To be more specific, quicksort is not generally the fastest algorithm, it's actually considered unreliable and there are very good reasons for that. Even my friends who had no idea what the three xors did know why quicksort is bad (and they've built their own hardware and protocols for wireless communication and a wiimote workalike).
Crap, I keep forgetting myself!
Crap, I keep forgetting myself!
- Jim e
- Calc King
- Posts: 2457
- Joined: Sun 26 Dec, 2004 5:27 am
- Location: SXIOPO = Infinite lives for both players
- Contact:
I knew you'd keep posting...
The low level optimizing you want to do is changing the code so it does the exact same thing but in a different better way. Problem is Compilers WILL disagree with you, so unless you are programming in assembly its very unlikely that you can improve low level. Especially with all these new fangled high level languages.
High level optimization, which everyone is saying is more important, is changing the actual workings of the code, it no longer does the same thing, but will achieve you goal in a better way.
I mean you could low level optimize the hell out of a sort routine but that doesn't really improve it to much... Go take a look at the programming contest MaxCoderz had, 15 byte routines all utterly worthless.
High level also has the benefit of being mostly portable to multiple machines, where as low level requires knowledge of the machine and what does best on it.
No not quicksort...and even if you say there is a fastest that still doesn't mean best. You need to use whats appropriate for what your doing.King Harold wrote:well.. isn't quicksort generally the fastest algorithm anyway? meaning it's already high-level optimized - which leaves low lvl optimizing.
The low level optimizing you want to do is changing the code so it does the exact same thing but in a different better way. Problem is Compilers WILL disagree with you, so unless you are programming in assembly its very unlikely that you can improve low level. Especially with all these new fangled high level languages.
High level optimization, which everyone is saying is more important, is changing the actual workings of the code, it no longer does the same thing, but will achieve you goal in a better way.
I mean you could low level optimize the hell out of a sort routine but that doesn't really improve it to much... Go take a look at the programming contest MaxCoderz had, 15 byte routines all utterly worthless.
High level also has the benefit of being mostly portable to multiple machines, where as low level requires knowledge of the machine and what does best on it.
- tr1p1ea
- Maxcoderz Staff
- Posts: 4141
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: I cant seem to get out of this cryogenic chamber!
- Contact:
... Isnt that what i said, i didnt say optimise the algorithm, i meant the routine. Perhaps there is a better implementation. But like already mentioned, quicksort isnt suited to all data nor can you use it on every machine effectively.King Harold wrote:well.. isn't quicksort generally the fastest algorithm anyway? meaning it's already high-level optimized - which leaves low lvl optimizing.
This thread is supposed to be about optimisation ideas, yet the only thing present is a basic demonstration of how xor works, which [typically] isnt even an optimisation.
Anyone have any real optimisations or quick C routines?
well if it's my own code, of course I'm going to make it readible or add comments. I did not intend to imply otherwise.CoBB wrote:But you will be going through at least your own old code quite often. You can’t expect yourself to remember how it works after a few weeks.crzyrbl wrote:I agree that readibility is important, but I don't really bother going through time.h or what have you, so I would rather it be insanely optimized rather than even somewhat readible.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Now now folks, the idea was to come up with something that no one would agree with so as to start a discussion. That part worked really well as you can see.
I know quicksort is not the best for all data sets, but it's generally the fastest isn't it? Fastest doesn't necessarily mean 'best' but it comes quite close to it, atleast if you don't want to spend a considerable percentage of the programs running time to sorting - it probably has better things to do of which the sorting is only a small part. Ofcourse, quicksort isn't the best when - forexample - the array is already mostly sorted - how about insertion sort? heap sort? -, or when the array is extremely short (like 2 elements long - in which case you only need to test which is bigger and decide whether or not to swap them).
now..
I know quicksort is not the best for all data sets, but it's generally the fastest isn't it? Fastest doesn't necessarily mean 'best' but it comes quite close to it, atleast if you don't want to spend a considerable percentage of the programs running time to sorting - it probably has better things to do of which the sorting is only a small part. Ofcourse, quicksort isn't the best when - forexample - the array is already mostly sorted - how about insertion sort? heap sort? -, or when the array is extremely short (like 2 elements long - in which case you only need to test which is bigger and decide whether or not to swap them).
that's to trick you into postingThis thread is supposed to be about "Swapping vars" according to the title.
now..
Anyone have any real optimisations or quick C routines?
I never saw the point with bringing up discussions with no conclusions, so far I haven't learnt a thing from this thread
Quicksort could be considered as "generally" the fastest, but you used that as an argument to condone low level optimization. When you do specific low level optimizing, then you don't have a "general" application anymore and thus a high level optimization will yield far better results.
If we're gonna get into optimized routines, then a change of the thread title might be in order?
Quicksort could be considered as "generally" the fastest, but you used that as an argument to condone low level optimization. When you do specific low level optimizing, then you don't have a "general" application anymore and thus a high level optimization will yield far better results.
If we're gonna get into optimized routines, then a change of the thread title might be in order?