Very simple benchmark.
cpp source vs c source
This presents usage of string concatenation operators in c and c++.
C is up to 20 times faster on different compilers on small strings.
(However it just 3 times faster on my CentOS if outer loop increased up to 10000)
[rtg@rtgCent cpp_vs_c]$ g++ -O3 ppstr.cpp -o ppstr
[rtg@rtgCent cpp_vs_c]$ gcc -O3 cstr.c -o cstr
[rtg@rtgCent cpp_vs_c]$ sudo time nice -n -10 ./ppstr
[rtg@rtgCent cpp_vs_c]$ sudo time nice -n -10 ./cstr
(or xlC instead of g++ and gcc if you have IBM compiler)
No comments:
Post a Comment