|
what does the compiler turn those into and what's the CPU word size?
|
|
|
|
|
You mean it might be code that assumes a particular multi-platform optimizing compiler?
And only if the index has no other function than to "iterate"?
And refactoring is not an option?
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I mean: where does the code in question run? And what does the compiler generate, and how does that mesh with the target CPU?
If it's hardware that's going to space, it's probably not running on a common commercial CPU, so you can't make assumptions about word size and what a 'short' is, etc..
[I don't actually know which code you're talking about]
Gerry Schmitz wrote: And refactoring is not an option?
if it's commented as being there for performance reasons, you can probably assume it was profiled and tested for performance.
|
|
|
|
|
You make a lot of assumptions.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
WTF.
if you don't know anything about the hardware that runs it, you can't make assumptions about the software.
|
|
|
|
|
It can run on anything with a C compiler. I could put it on my phone / watch.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
maybe it can run on anything with a C compiler ... as long as it was deliberately written to work on any OS with any CRT implementation, using no system-specific libraries, and making no assumptions about the underlying hardware.
the C spec only specifies minimum sizes for short, int and long. int and short must be at least 16 bits. long must be at least 32 bits.
so what any of those types means in terms of storage and CPU handling (aka performance) depends on the compiler and the target architecture.
|
|
|
|
|
They've built a Python shell for it. Does that help or confuse?
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
No, your assessment that they're making an invalid tradeoff is the assumption. JPL writes real-time code for memory limited systems that cannot fail. Their use case is far different from almost everyone else.
|
|
|
|
|
When is the code from? There are times were storage does matter alot more than performance. And in the past for NASA they had some very strict storage requirements. I can see this being a huge discussion at the code review.
Interesting to say the least.
Me no, I never really think about it. I almost always use an int and move on with life.
To err is human to really elephant it up you need a computer
|
|
|
|
|
rnbergren wrote: I never really think about it. I almost always use an int and move on with life.
exactly.
|
|
|
|
|
"Not thinking" is not something I ever boasted about. It was a thought exercise; regardless of what the compiler "might do".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
an int is just fine. for me, it is a no brainer. If you want to spend hours thinking about it, go for it.
|
|
|
|
|
Re: storage; it's "one variable".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Well,
Gerry Schmitz wrote: In some cases, their loop variable is an int; in others a short; in others a long. Modern compilers will promote those loop variables to 32/64 bit depending on target architecture. If you are looking at old code... there were reasons to use integer BOOL for performance and 8 bit bool for smaller code-size many years ago. Optimizing compilers today make most of that pointless.
I am finally getting around to reviewing that json library @code-witch keeps obsessing over. First thing I noticed was the liberal use of bool. But in the end... it does't really matter the compiler should promote some of these.
Best Wishes,
-David Delaune
|
|
|
|
|
I expect promotion. The reason I use things like bytes and half words is so they fit better on 8bit. I am expecting a lot out of it in terms optimization on a 32 or 64 bit machine. My code favors 8bit it as a result
Real programmers use butterflies
|
|
|
|
|
Oh Well,
I wish you would have commented sooner. I found a bug in your json parser but didn't want to tarnish your article comment section.
Let me know if you want to discuss it here and I'll go over and delete it.
|
|
|
|
|
I'm about to fix it. I was at sister's yesterday so I couldn't.
Real programmers use butterflies
|
|
|
|
|
I have the whole application up and running and have gone through all the code and docs.
They use random access binary files containing millions of doubles.
Storage is / was not a problem.
I thought it was an interesting mental exercise in light of some of the "performance" discussions going on.
Nothing more. We can all stop "thinking" now.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Working in industrial sector... there are still devices that struggle with memory and therefore I use BYTES for counters when I can, same for the states machine controller variable...
So for me it's a yes.
|
|
|
|
|
I worked with PLC's, etc.
Never had to sweat 1 or 2 bytes; getting the storage architecture right was more important.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Lucky you.
If I choose the material to be used I never have to... but when the customer gives me the material then everything can happen.
|
|
|
|
|
The customer ordered it, the hardware company built it, I had to program it (contract). There were no choices.
The hardware company used my software to debug their firmware. (Only way to avoid finger pointing).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I'm glad you've been so lucky.
Congratulations.
|
|
|
|
|
I have always preferred the 2 bytes distribution for variables (WORD or INT) due to the endian changes, it is already painful enough to deal with it without having to increase the difficulty messing with more than a variable in the "same space"
On the other hand, when staying in the PLC I have used a lot of BYTE variables. Specially when grouping bits to be masked or moved from one place to another.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|