Author: Russell Reagan
Date: 09:09:44 08/28/03
Go up one level in this thread
On August 28, 2003 at 04:08:00, Steven Edwards wrote: >The slowdown is dependent on a number of factors. One of them is the use of >base classes with member data that increases object size. A big slowdown comes >from using class polymorphism as a vtable (or similar) needs to be created (and >scanned) for each object of a polymorphic class. I didn't use any base classes or virtual anything in any of those classes. All just wrappers for the "C way" you would do those simple types. >My observation is that non polymorphic class objects, particularly those using >default constructors and destructors, have no real performance penalty over >using C language struct variables. Maybe that is where the difference lies. The slowdowns occured when using non-struct variables (ex. color, square). When using struct variables, there is no pointer overhead, becuase you would have passed a pointer anyway. For instance, instead of the implicit this pointer when doing this: void Board::MovePiece (Square from, Square to); You would do: void MovePiece (Board * board, Square from, Square to); So you pass the pointer either way. The slowdown occurs when you use a non-struct type. >Some compilation options can dramatically decrease run time performance. >Support for dynamic type ID can be a killer. Dynamic binding as in Objective C >can require a search of a hash table of method names / addresses for each call. >Use of the run time exception processing scheme (try / catch / raise) can add a >big penalty in some cases. I tinkered with the compiler settings to try and get a speedup, because I figured the pointer overhead might be avoidable. I did get the version that uses classes to go faster, but when I recompiled the non-class version using the same settings, it also went faster, by the same percentage.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.