Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

It's not always as simple as that. Doing lots of if tests is also more inefficient and will require more CPU cycles because they are redundant. Many people use flags but they are redundant waste of memory and CPU cycles.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Matthew wrote:It's not always as simple as that. Doing lots of if tests is also more inefficient and will require more CPU cycles because they are redundant. Many people use flags but they are redundant waste of memory and CPU cycles.
That's not much of an argument considering that these days decent processors usually start at 2.0GHZ and that is WAAAAY more than enough to handle a bunch of if statements.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

That's no way to think. Also weren't we discussing PIC chips.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Matthew wrote:That's no way to think. Also weren't we discussing PIC chips.
I thought we had gone back to console applications again. Because, personally, for console apps memory management and CPU cycles aren't bothering me because of the power of a computer. The app would have to contain lots of loops to bog down any computer (at the console level).
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

It's all relative. Powerful processors can run inefficient programs fast but you could run them even faster if they were efficient. Fast processors are no excuse to slack on software.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Matthew wrote:It's all relative. Powerful processors can run inefficient programs fast but you could run them even faster if they were efficient. Fast processors are no excuse to slack on software.
Well I don't purposely write terribly inefficient software. I was just saying that I don't necessarily worry my self silly over small things but often go back and fix some stuff afterwards. I'm not exactly a literal guy, but I can see the confusion.

Oh, and I never had to use that if statement to break idea before, it was just something I thought up to counter act your point. I still don't feel it's that big of a hog though.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

It adds up. If you were using loops often and there was very simple arithmetic being fone with it, the if tests could take a reasonable amount of processing time relative to everything else. It accumulates with further inefficiencies.

I think it's a good habit to avoid redundant data and processing where possible. Even if it's small, it helps the habit and can add up to make a program reasonably faster.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Matthew wrote:It adds up. If you were using loops often and there was very simple arithmetic being fone with it, the if tests could take a reasonable amount of processing time relative to everything else. It accumulates with further inefficiencies.
Well I'm sure in a situation where someone would use my provided code, a different solution could also work.
Matthew wrote:I think it's a good habit to avoid redundant data and processing where possible. Even if it's small, it helps the habit and can add up to make a program reasonably faster.
Well ya :)-

Oh, and in case you skipped over it, or ignored it ( :( ) I found a cool "programming" language: processing.org I put programming in quotes for a reason. It's a fairly neat thing nonetheless. And no, it's not a joke language.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

The language is weird though.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Matthew wrote:The language is weird though.
I was expecting a more robust answer from you, but yes, yes it is :lol:

I think it was to teach programming to people who are more visual. Personally it screws me right up. Regardless, it's a neat language and I plan on fooling around with it a bit in case I find a solid use for me.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

Why not just create a library for another language with functions like make_funky_circle()?
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Matthew wrote:Why not just create a library for another language with functions like make_funky_circle()?
Me? Because I don't know how to do that. Them? I have even less of an idea.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

Yes, them.

My converter library has a memory leak. The leak happens constantly about 1MB a second. Since it's constantly reallocating more and more memory all the time, it slows down a lot also.

I can't get accurate readings on the performance gain vs CPython until this is sorted.

http://stackoverflow.com/questions/3840 ... realloc-im
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

A memory leak is when an allocated piece of memory isn't set free correct?
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

Not necessarily, it can simply be memory which is allocated too much.

In this case, that is what is happening. Something is being reallocated as it should be and is constantly growing when nothing needs to grow so much.
Post Reply