I saw something unusual with the Apache library concerning a timing
comparison against the MSVC 7.1 native Standard library. It may be
insignificant or something that is already known and remedied, but I can't
find an e-mail referencing the problem or possible solutions.
I took the code from partsum.cpp and modified it to give me usr time and sys
time for a certain number of repetitions of the test. It first creates a
vector of values of 1 to 15, then creates two empty vectors to store
results. It then computes the partial sum for sums and products for the
values in a loop for the specified number of repetitions. It does not do
any output of the results to a file or the screen. It keeps writing the
results to the two vectors to store them, then overwrites those results with
each iteration.
I tested the Apache Standard library using MSVC 7.1 against the native
library from Microsoft on Windows XP. Here are my timing results (usr time
in seconds):
Microsoft Tests: Apache Tests:
100,000 Repetitions 100,000 Repetitions
0.15625 seconds 0.31250
0.31250 0.31250
0.31250 0.31250
0.31250 0.31250
0.15625 0.15625
No problem at 100,000 repetitions.
Microsoft Tests: Apache Tests:
10,000,000 Repetitions 10,000,000 Repetitions
0.656250 seconds 0.812500
0.656250 0.796875
0.656250 0.812500
0.656250 0.812500
0.656250 0.796875
It is getting a little slower at 10,000,000 repetitions.
Microsoft Tests: Apache Tests:
100,000,000 Repetitions 100,000,000 Repetitions
6.421875 seconds 7.906250
6.406250 7.906250
6.421875 7.906250
6.406250 7.906250
6.406250 7.906250
Now it is about 1.5 seconds slower.
Here is the main code for the program:
//The main work is done here, then see what the time is.
typedef std::vector<int, std::allocator<int> >
Vector;
typedef std::ostream_iterator<int, char, std::char_traits<char> > Iter;
// Initialize a vector using an array of integers.
const Vector::value_type a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15 };
Vector v (a + 0, a + sizeof a / sizeof *a);
// Create an empty vectors to store results.
Vector sums (Vector::size_type (15));
Vector prods (Vector::size_type (15));
// Compute partial_sums and partial_products.
for (i = 0; i < repetitions; i++){
std::partial_sum (v.begin (), v.end (), sums.begin ());
std::partial_sum (v.begin (), v.end (), prods.begin (),
std::multiplies<Vector::value_type>());
}
I don't know if I should be concerned with this delay or not. Is this delay
significant enough to investigate?
Craig Chariton
|