Boost logo

Boost Users :

From: KSpam (keesling_spam_at_[hidden])
Date: 2007-11-28 22:55:04


Nisha

> Im a quite new boost user and I wonder, why C++ Program is so slow.
>
> I wrote a program, and I have the same program in Matlab,
> I expected that my C++ version is much faster, but its not.
>
> I use matrices, vectors, matrix- and vector proxies. Do some
> solving and compute calculations with prod, element_div, etc..
>
> Is boost in general slower than matlab, should I use something
> else?
>
> Id be real happy about any help.

This is unfortunately a very broad question, and the way it is worded will
make it difficult to answer. In general, a compiled language such as C++
will be faster than an interpreted language such as Matlab. However, as with
all computing languages, it is very possible to use C++ (and/or Boost)
improperly or inefficiently.

Perhaps, the best way to obtain help would be to post a small code example
that exhibits the performance problem you are seeing. It would be good to
see the Matlab and C++ equivalents that you are trying to compare.

With C++, compilation settings (compiler flags and defines) make a significant
difference. For instance, many additional checks are done on the running
code when it is compiled in debug mode. The checks are great for making sure
that the code works properly, but they should be disabled for release builds
in order to obtain optimal runtime performance. It is generally a good idea
to compile with NDEBUG defined when building in release mode.

Additionally, it is always good to get familiar with profiling tools. These
tools make it easier to spot performance bottlenecks in your code.

Hope This Helps,
Justin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net