c++ - Speed of finite state machines - OO vs procedural -


hey all,
designing program accept input series of tokens , feed them finite state machine have designed. have designed test finite state machine in object-oriented style, structs machine , transitions, etc. application writing 1 speed important.

so far, using machine, adding new states , like, has proven easy , not complicated. easy comprehend , leaving month , coming code not disorienting. however, not sure speed trade off current oo approach. allocation of objects, storage of data, etc. take away of speed had using bunch of labels , goto statements?

rather thinking in terms of oo being slower functional or procedural programming think in terms of operations. calling function, branching, fetching, storing etc... take time , idea of performance of each solution you'd need tally how of each of these you'll need do.

the best way use oo test solution , see if it's fast enough. if not profile it, work out branches or stores costing , see if can avoid or streamline them. re-architect solution until meets performance goals you're after. may in cases you'll have adopt more functional or procedural style.

lastly if code single function consists of hundreds of stack variables , goto you've done wrong. code must readable , maintainable.

extra thought: can spend $5,000 on better hardware avoid $50,000 in development costs optimising?


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -