Well, after some hours of programming I changed my implementation
but.....it is even slower right now !!
What did I do:
1) All the Point objects in my Hashtable now have 4 fields and the
coordinates are now Vectors instead of int* coordinates. Moreover de
destructor is empty now:
using namespace std;
class nDimPoint2
{ public:
vector<intcoordinates;
double valueReal;
double valueImag;
long code;
nDimPoint2();
nDimPoint2(vector<int_coordinates, double
_valueReal, double _valueImag, int useless);
~nDimPoint2();
};
2) My Hasttable before was structured as:
vector<vector<nDimPoint2* myHashTable2;
but now it is a vector<vector<nDimPoint2 myHashTable2;
There are no NEW or DELETE statements anymore in my programm.
But now my program is even slower than before. Again calling clear()
on all the vectors of the vector of my Hashtable takes a lot of time.
Some timings:
old implementation with clearing the Hashtable: 15 seconds,
old implementation without clearing the Hashtable: 8 seconds (memory
leak!!),
new implementation with clearing the Hashtable: 46 seconds,
new implementation without clearing the Hashtable: 14 seconds (memory
leak!!) for each 1000 iterations.
Horrible ! I'm asking myself why does it get even slowwer now !?!?
I'm was not such a bad programmer before ! :)
I made a profile report of the function calls and timings with my
Visual C++ 6.0 and most of the time is spent in function that are not
mine:
Func Func+Child Hit
Time % Time % Count Function
---------------------------------------------------------
179,137 9,7 179,137 9,7 463149 operator delete(void *)
(delop.obj)
143,360 7,8 143,360 7,8 332055 std::_Allocate(int,int
*) (main.obj)
116,819 6,3 160,788 8,7 821015 std::_Construct(int
*,int const &) (main.obj)
85,135 4,6 144,643 7,9 821015
std::allocator<int>::destroy(int *) (main.obj)
84,776 4,6 245,563 13,3 821015
std::allocator<int>::construct(int *,int const &) (main.obj)
67,266 3,7 67,266 3,7 728284 std::vector<int,class
std::allocator<int::size(void) (main.obj)
66,493 3,6 274,364 14,9 477501 std::vector<int,class
std::allocator<int::_Ucopy(int const *,int const *,int *)
59,765 3,2 204,408 11,1 471928 std::vector<int,class
std::allocator<int::_Destroy(int *,int *) (main.obj)
59,508 3,2 59,508 3,2 821015 std::_Destroy(int *)
(main.obj)
58,582 3,2 413,719 22,5 237988 std::vector<int,class
std::allocator<int::vector<int,class std::allocator<int>
>(class
std::vector<int,class std::allocator<int const &) (main.obj)
54,782 3,0 326,831 17,7 144218 std::vector<int,class
std::allocator<int::insert(int *,unsigned int,int const &)
48,033 2,6 48,033 2,6 915739 operator new(unsigned
int,void *) (main.obj)
47,647 2,6 47,647 2,6 587227 std::vector<int,class
std::allocator<int::begin(void) (main.obj)
42,473 2,3 137,866 7,5 85141 std::vector<int,class
std::allocator<int::operator=(class std::vector<int,class
std::allocator<int>
const &) (main.obj)
41,345 2,2 383,897 20,8 144218 std::vector<int,class
std::allocator<int::insert(int *,int const &) (main.obj)
38,279 2,1 345,354 18,7 312125 std::vector<int,class
std::allocator<int::~vector<int,class std::allocator<int>
37,020 2,0 180,380 9,8 332055
std::allocator<int>::allocate(unsigned int,void const *) (main.obj)
36,508 2,0 36,508 2,0 323129 std::vector<int,class
std::allocator<int::end(void) (main.obj)
35,878 1,9 66,832 3,6 284784 std::vector<int,class
std::allocator<int::operator[](unsigned int) (main.obj)
28,804 1,6 188,081 10,2 406192
std::allocator<int>::deallocate(void *,unsigned int) (main.obj)
24,556 1,3 24,556 1,3 324357 std::vector<int,class
std::allocator<int::begin(void) (main.obj)
21,678 1,2 21,695 1,2 2
std::_Locinfo::_Locinfo(char const *) (locale.obj)
21,069 1,1 58,762 3,2 144218 std::vector<int,class
std::allocator<int::_Ufill(int *,unsigned int,int const &)
18,090 1,0 1129,281 61,3 2673
ndSystem2::trackPoint(class std::vector<int,class std::allocator<int>
>) (main.obj)
17,757 1,0 56,407 3,1 21132
hashTable2::codeer(class std::vector<int,class std::allocator<int>
>,int) (main.obj)
16,593 0,9 476,780 25,9 15777
hashTable2::searchValueOfPoint(class std::vector<int,class
std::allocator<int,int)
15,675 0,9 407,218 22,1 144218 std::vector<int,class
std::allocator<int::push_back(int const &) (main.obj)
13,974 0,8 13,974 0,8 108697 std::vector<class
std::vector<int,class std::allocator<int,class
std::allocator<class
std::vector<int,class std::allocator<int ::size(void) (main.obj)
13,728 0,7 13,822 0,8 1 std::num_put<char,class
std::ostreambuf_iterator<char,struct std::char_traits<char
>::do_put(class
std::ostreambuf_iterator<char,struct std::char_traits<char,class
std::ios_base
&,char,double) (main.obj)
13,401 0,7 13,401 0,7 28674
std::_Allocate(int,class nDimPoint2 *) (main.obj)
etc etc.
I would almost think that the whole design of my implementation is
bad.....
Any suggestions ??
Best regards,
Brey