TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Paul Edwards
date: 1996-08-30 00:45:56
subject: Passing a var.

PE> Show me the C++ code you think would be slower if written in C. Or
PE> better  still, write both the C and C++ versions, and have a look 
PE> at the assembler generated for each, and look at the 
PE> relative code.  They should be the same (speedwise).  BFN.  

FA> NO WAY, NO HOW am i getting into a C vs. C++ argument, but if i had to use 

Doing "performance tuning" without the grottiness of actually
using profiler, looking at assembler etc, eh?  :-)

I know someone who was telling me how great dynamic SQL is under Informix,
once it's prepared it's really fast.  He's based thousands upon thousands
of lines of SQL on this.  I didn't for a moment believe that dynamic SQL
would be faster than static SQL, which simple timings would have shown.  So
I asked him if he'd actually timed it.  Er, well, um er.

FA> structures and pass them to individual functions, i would assume that a 
FA> single class using local(to it) variables would speed things up.

How did you think those C++ functions would know which object they were
acting on?  ESP?  Just happened to be sitting in a register, guv'ner.

FA> Hold the mail, just tested the runtimes..compiled on TC2, small.

FA> c2.exe Average elapsed time = 0.0253956 seconds
FA> c1.exe Average elapsed time = 0.0245724 seconds
FA> c1.exe is 0.0008232 seconds faster than c2.exe 

FA> Dammit ! C1 is the C version. Don't you hate that ?!

No?

FA> Chucked it into tprof also, 'cause i'm a bit sus about that timer 
FA> program. Especially now. :)
FA> Ran 'em 10 times, came between .0082-.0088 for C2 and .0082-0.0087 for C1.
FA> So although nothing in it the C did get the fastest time still.

The idea is to run it 1000's of times so you get decent times, like 10-30
seconds.  Also, you should eliminate the crap from within the code, to just
test the function-calling overhead.

FA> Isn't David (our C++ guru) going to help me out here ? :-)

When a duck is dead, it doesn't quack anymore.

You do realise that the original C++ was just a translator that produced C
code, don't you?  Ergo, whatever was done in C++ can be done in C.  In the
above case, going x.func() is the equivalent of going xfunc(&x).  Or at
least, that's my understanding of it.  BFN.  Paul. 
@EOT:

---
* Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.