Whell I did a small test application to test the usage of boost::pool_allocator and boost::fast_pool_allocator. My application will possibly do a lot of transition from a state to another. I found that it is better to use state chart classes without allocator. In the code below tese are the results: - Without allocator 5.7 sec - with boost::pool_allocator 10.7 sec - with boost::fast_pool_allocator 8.7 sec Next action could be - test with another allocator - try the asynchronous version Any suggestion? #include <boost/statechart/simple_state.hpp> #include <boost/statechart/state_machine.hpp> #include <boost/statechart/event.hpp> #include <boost/statechart/transition.hpp> #include <boost/timer.hpp> #include <boost/progress.hpp> #include <boost/pool/pool_alloc.hpp> using namespace boost::statechart; struct state_1; struct state_2; struct state_3; struct state_4; struct main_machine : state_machine< main_machine, state_1 // without allocator I have 5.6 seconds (used also in events) //,boost::pool_allocator< main_machine > // with this // allocator I go to 10 sec used also in events //,boost::fast_pool_allocator< main_machine > // with this //allocator I go to 8.7 sec
{};
struct event_1_2 : event< event_1_2 //, boost::fast_pool_allocator< event_1_2 >
{}; struct event_2_3 : event< event_2_3 //, boost::fast_pool_allocator< event_2_3 > {}; struct event_3_4 : event< event_3_4 //, boost::fast_pool_allocator< event_3_4 > {}; struct event_4_1 : event< event_4_1 //, boost::fast_pool_allocator< event_4_1 > {};
struct state_1 : simple_state< state_1, main_machine > { typedef transition< event_1_2, state_2 > reactions; }; struct state_2 : simple_state< state_2, main_machine > { typedef transition< event_2_3, state_3 > reactions; }; struct state_3 : simple_state< state_3, main_machine > { //typedef transition< event_3_4, state_4 > arc; // it doesn't work typedef transition< event_3_4, state_4 > reactions; //state_3(){std::cout<<"3";} //~state_3(){std::cout<<"~3";} }; struct state_4 : simple_state< state_4, main_machine > { typedef transition< event_4_1, state_1 > reactions; }; void main(){ main_machine fsm; fsm.initiate(); { boost::progress_timer t; // count the time elapsed // before distruction: not very precise // for expected big differences for( int i = 0; i < 1000000; i ++ ){ fsm.process_event( event_1_2() ); fsm.process_event( event_2_3() ); fsm.process_event( event_3_4() ); fsm.process_event( event_4_1() ); } } } On Thu, Nov 26, 2009 at 4:57 PM, Eric J. Holtman <eric@holtmans.com> wrote:
Conoscenza Silente wrote:
I would like to fasten up the whole process; let's say that I would like to avoid the creation/destruction of the class each time using object already allocated in memory that are deleted only at the exit of the application. Is this a good way in your opinion ?
So when you profile your entire application, how much time is being spent in boost's state library? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users