I was mainly curious as to why bcharge was CPP compiled, since the
code itself was just your basic procedural stuff. I wondered "would it
be smaller as c?" and "what about linked libs?" so I played around for
a few secs.
bcharge.cc was easily converted to bcharge.c by replacing the two
'bool' uses with 'int' and using simple 0 and 1, as well as changing
the argv check for -o into a simple (a ? b : c) case. I also removed
unistd.h, not needed.
$ gcc -o bcharge-c bcharge.c -lusb
$ strip -d bcharge-c
$ ls -l bcharge-c
... 6983 Mar 22 15:44 bcharge-c
$ ldd bcharge-c
linux-gate.so.1 => (0x00137000)
libusb-0.1.so.4 => /usr/lib/libusb-0.1.so.4 (0x00533000)
libc.so.6 => /lib/libc.so.6 (0x00138000)
/lib/ld-linux.so.2 (0x00dd6000)
$ g++ -o bcharge-cpp bcharge.cc -lusb
$ strip -d bcharge-cpp
$ ls -l bcharge-cpp
... 7565 Mar 22 15:47 bcharge-cpp
[EMAIL PROTECTED] /home/tengel/bar]
$ ldd bcharge-cpp
linux-gate.so.1 => (0x00ff2000)
libusb-0.1.so.4 => /usr/lib/libusb-0.1.so.4 (0x00533000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x07192000)
libm.so.6 => /lib/libm.so.6 (0x00240000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x07184000)
libc.so.6 => /lib/libc.so.6 (0x00101000)
/lib/ld-linux.so.2 (0x00dd6000)
OK, so we have a slightly smaller binary that links to 3 less
libraries. Does not linking to C++ libs give us any benefit? (ignore
the 'not a Pearl', this is the broken CVS code)
(unplug and plug in device)
$ time ./bcharge-c
Scanning for Blackberry devices...
Found device #002...adjusting charge setting...not a Pearl...done
real 0m0.003s
user 0m0.001s
sys 0m0.002s
(unplug and plug in device)
$ time ./bcharge-cpp
Scanning for Blackberry devices...
Found device #003...adjusting charge setting...not a Pearl...done
real 0m0.005s
user 0m0.002s
sys 0m0.002s
We gain a bit of time back -- I mean we're talking a super low amount
of time here, just the blink of an eye. But still, would there be a
compelling reason to kep bcharge as a CPP compiled binary instead of
switching to C?
-te
--
How can anyone hate Canadians? It's like hating bread.
[Matt Harding]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Barry-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/barry-devel