significantly reduced sparse matrix footprint:
http://code.opencv.org/issues/2206, http://code.opencv.org/issues/2924
This commit is contained in:
@@ -1248,3 +1248,27 @@ TEST(Core_SVD, orthogonality)
|
||||
ASSERT_LT(norm(mat_U, Mat::eye(2, 2, type), NORM_INF), 1e-5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Core_SparseMat, footprint)
|
||||
{
|
||||
int n = 1000000;
|
||||
int sz[] = { n, n };
|
||||
SparseMat m(2, sz, CV_64F);
|
||||
|
||||
int nodeSize0 = (int)m.hdr->nodeSize;
|
||||
double dataSize0 = ((double)m.hdr->pool.size() + (double)m.hdr->hashtab.size()*sizeof(size_t))*1e-6;
|
||||
printf("before: node size=%d bytes, data size=%.0f Mbytes\n", nodeSize0, dataSize0);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
m.ref<double>(i, i) = 1;
|
||||
}
|
||||
|
||||
double dataSize1 = ((double)m.hdr->pool.size() + (double)m.hdr->hashtab.size()*sizeof(size_t))*1e-6;
|
||||
double threshold = (n*nodeSize0*1.6 + n*2.*sizeof(size_t))*1e-6;
|
||||
printf("after: data size=%.0f Mbytes, threshold=%.0f MBytes\n", dataSize1, threshold);
|
||||
|
||||
ASSERT_LE((int)m.hdr->nodeSize, 32);
|
||||
ASSERT_LE(dataSize1, threshold);
|
||||
}
|
||||
|
Reference in New Issue
Block a user