Re: C vs C++
CRPence <[email protected]>
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Organization | midrange.com |
| Message-ID | <[email protected]> |
On 16-Feb-2015 08:56 -0600, Jevgeni Astanovski wrote: > > Does anyone have any idea why C++ program is significantly slower than > C program? > > Explain the situation. > I have a number of APIs that are called via RPC, access some tables, > make some calculations and return some structures to the caller. > They've all been written on ILE/C. > Recently I started to experiment with porting them to ILE/C++. > <<SNIP>> > > What I saw is that time increase looks like it has a proportional > nature. I tested API in 3 cases (number of tests is over 100): > simple request, medium request; complicated request > > and the timing is: > • Simple C: 1ms; Simple C++ : 2ms > • Medium C: 3ms; Simple C++ : 7ms > • Long C: 25ms; Long C++: 60ms. > > The difference is in number of records read from table and a number > of calculations. That is, a > • simple one retrieves less that 10 records; > • medium - more than 10 and > • long - more than 100. Program makes a lot of calculations > with packed decimal. > > Any idea why it is like that Followups determined the issue is apparently for the calculations using the Packed BCD numeric data type using the C++ libraries. > and is there anything that can be done about it? With so few specifics of the scenario, the following may be way off the mark, but as a possibility: Perhaps the /calculations with packed decimal/ over data that is apparently /record data/ of /some tables/ could be performed by the SQL? -- Regards, Chuck -- This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected] To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/c400-l or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected] Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.