Search This Blog

Pages

Wednesday, February 24, 2010

Simple timer class in C++

Copied from http://www.dreamincode.net/code/snippet344.htm

/*
  Simple timer class
  ==================
  History:

  Created - Sarah "Voodoo Doll" White (2006/01/26)
  ==================
  Description:

  A quick and easy timer class to save people
  from using ad hoc timers. The constructor
  begins the timer and the end() member function
  stops it, as well as returns the result.
  Before starting the timer again with begin(),
  users can see the last result with last()...

  So unintuitive. ;)
  ==================
  Bugs:

  The timing method used is neither strictly
  portable, though it only uses standard
  functions, nor is it guaranteed to support
  timing resolution less than a second.
*/
#include

class Timer {
public:
  typedef double diff_type;

  // Same as Timer t; t.begin();
  Timer(): start(std::clock()), elapsed(0) {}
  // Last result before a call to begin()
  diff_type last() const { return elapsed; }
  // Reset the timer
  void begin() { start = std::clock(); elapsed = 0; }
  // Save the result
  diff_type end();
private:
  std::clock_t start;
  diff_type    elapsed;
};

Timer::diff_type Timer::end()
{
  elapsed = (diff_type)std::clock() - start;
  elapsed /= CLOCKS_PER_SEC;
  return elapsed;
}

Piping Commands - Find, Grep, Sed

I wanted to perform sed on output of grep. Found that the webpage: http://www.liamdelahunty.com/tips/piping_commands_find_grep_sed.php matches my requirement.

The following command worked:
$ grep SHASHI rscd.log  | sed 's/.*SHASHI/SHASHI/g'

Time to invest in floating rate funds

Now that inflation has risen to record levels, RBI is sure to take measures to curb it by reducing availability of money in the market. That will be done by hiking various mandatory ratios. This leads to hike in interest rates (benchmark prime lending rates) of banks.

Floating rate debt funds are the funds to purchase in this rising interest rate regime to earn maximum returns. More about floating rate funds can be read at:

http://www.financialexpress.com/printer/news/113055/ 
http://www.fourstocks.com/blog/200912/analyzing_floating_rate_funds/426 
http://valueinvestorindia.blogspot.com/2009/12/analysing-floating-rate-funds.html

Higher returns can be expected from Long term floating rate funds over short term. A snapshot of list of long term floating rate funds is available at:
http://new.valueresearchonline.com/funds/h2_typecomp.asp?type=1&objective=34

An important point to keep in mind is that floating rate funds are good only when you are ready to invest for at least more than 1 year. Otherwise the exit loads on these funds are very big. Examples:


Fund                                                                               Exit load
====                                                                             =======
BSL Floating Rate LT Ret-G                           2% for redemption within 365 days
HDFC Floating Rate Income LT-G                  3% for redemption within 540 days
ICICI Pru LT Floating Rate A-G                      4% for redemption within 390 days



Information about all fund categories in debt is available at:
http://wealth.moneycontrol.com/printpage.php?id=13992

Update: Sunday 14th March 2010
========================
My thoughts proved to be correct as seen from the article at link below which discusses the returns of all debt fund categories in the month of February 2010. The essence is that floating rate long term funds was the best performing category of the month.

http://new.valueresearchonline.com/story/h2_storyView.asp?str=101297

Tuesday, February 23, 2010