January 23, 2010
clojure + latex
Here is small addition for great 'listings' package, that allows to put Clojure code into LaTeX documents
January 21, 2010
new domain for home page
I moved my home page to separate domain - http://alexott.net/, but all links to old pages should work as before, with redirection to new address...
January 18, 2010
Coders at Work
Just finished reading of Coders at Work. Although this is read-once book, but it worth to read it - you can get some view of how well-known software developers are working and thinking.
All these peoples have different stories, but some of them have pretty much common. For example, many of them use debug print with careful reading of code to tackle bugs, and don't use interactive debuggers. Many of them use Emacs as editor, including Google's Chief Java architect.
So, if you'll get a chance to read this book, it worth to spend some time reading it....
All these peoples have different stories, but some of them have pretty much common. For example, many of them use debug print with careful reading of code to tackle bugs, and don't use interactive debuggers. Many of them use Emacs as editor, including Google's Chief Java architect.
So, if you'll get a chance to read this book, it worth to spend some time reading it....
January 6, 2010
boost.spirit2 vs. atoi
I did very primitive test of performance for new version of boost.spirit. I read somewhere, that boost.spirit v.2 over-performs atoi on parsing of integers, and I decided to check this with help of program, shown below. With compilation in release mode, and for 10000000 iterations, I got following results:
atoi = (10000000 rep): 00:00:00.404165 spirit = (10000000 rep): 00:00:00.043559Update: I slightly modified parser so it will handle whitespace before numbers (as atoi does), and still have better results for boost.spirit:
atol = (10000000 rep): 00:00:00.411694 spirit = (10000000 rep): 00:00:00.112000Next, I'll do tests for complex parsers.
#include <boost/spirit/include/qi.hpp> #include <iostream> #include <boost/date_time/local_time/local_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp> using namespace boost::spirit; typedef void (*void_func)(int); void measure_time(const char *str, void_func func, int number_of_repeat) { using namespace boost::posix_time; ptime tStart = microsec_clock::local_time(); (*func)(number_of_repeat); ptime tEnd = microsec_clock::local_time(); time_duration tVal = tEnd - tStart; std::cout << str << " (" << number_of_repeat << " rep): " << to_simple_string(tVal) << std::endl; } const char* nstr="123456"; const char* const nstr2="123456"; void test_spirit(int number_of_repeat) { int val=0; for(int i=0; i < number_of_repeat; i++) { qi::parse(nstr,nstr+6,int_,val); if (val != 123456) std::cout << "Spirit Errror! val=" << val << std::endl; } } void test_atol(int number_of_repeat) { long val=0; for(int i=0; i < number_of_repeat; i++) { val=atoi(nstr2); if (val != 123456) std::cout << "Atoi Errror! val=" << val << std::endl; } } int main(int /*argc*/, char **/*argv*/) { measure_time("atol =", test_atol, 10000000); measure_time("spirit =", test_spirit, 10000000); return 0; }
Subscribe to:
Posts (Atom)