Wednesday, April 29, 2015

VIM hex editing

http://usevim.com/2012/06/20/vim-binary-files/
http://blog.changyy.org/2010/01/vim-hex-mode-16.html
http://vim.wikia.com/wiki/Hex_dump
http://vim.wikia.com/wiki/Improved_hex_editing

Thursday, April 23, 2015

My choice of UML diagramming tool

When reading OO codes, it's always good habits to draw UML diagrams for them(Class diagram, Sequential diagram, etc.) to help memorizing them better.

Currently I choose ArgoUML:
ArgoUML is the leading open source UML modeling tool and includes support for all standard UML 1.4 diagrams. It runs on any Java platform and is available in ten languages.

Steps to download and install under Ubuntu:
1. Download http://argouml-downloads.tigris.org/nonav/argouml-0.34/ArgoUML-0.34.tar.gz
2. Unzip to ~/ws/pkg/argouml-0.34/
3. Run by java -jar ~/ws/pkg/argouml-0.34/argouml.jar
4. Have fun.

Tutorials:
http://www.objectmentor.com/resources/articles/umlClassDiagrams.pdf
http://creately.com/diagram-type/article/simple-guidelines-drawing-uml-class-diagrams
http://www.tutorialspoint.com/uml/uml_class_diagram.htm
http://www.visual-paradigm.com/features/uml-and-sysml-modeling/?src=google&kw=class%20diagram&mt=p&net=g&plc=&gclid=CjwKEAjwsOKpBRCDtfOnzaDg3HsSJAAJ2oji0gt4d4JNFeLU8-fEveRwYXuEsXVxsLP4lJasV5IPmhoCz-zw_wcB#class-diagram

Reference:
http://stackoverflow.com/questions/15376/whats-the-best-uml-diagramming-tool
http://argouml.tigris.org/


Sunday, April 5, 2015

Boost.PropertyTree

What is Property Tree?
http://www.boost.org/doc/libs/1_57_0/doc/html/property_tree.html#boost_propertytree.intro

Five Minute Tutorial
http://www.boost.org/doc/libs/1_57_0/doc/html/boost_propertytree/tutorial.html

How to Populate a Property Tree
http://www.boost.org/doc/libs/1_57_0/doc/html/boost_propertytree/parsers.html






What do real-user-sys mean in the output of time(1)

[From http://man7.org/linux/man-pages/man1/time.1.html and http://man7.org/linux/man-pages/man2/times.2.html]
---------------------------------------------------------------------------
(i)   the elapsed real time between invocation and termination,
(ii)  the user CPU time (the sum of the tms_utime and tms_cutime values in a struct tms as returned by times(2))
(iii) the system CPU time (the sum of the tms_stime and tms_cstime values in a struct tms as returned by times(2)).

real  = Elapsed real (wall clock) time
user  = tms_utime + tms_cutime
sys   = tms_stime + tms_cstime

struct tms {
  clock_t tms_utime;  /* user time */
  clock_t tms_stime;  /* system time */
  clock_t tms_cutime; /* user time of children */
  clock_t tms_cstime; /* system time of children */
};
---------------------------------------------------------------------------

[From Ubuntu "$ man time"]
---------------------------------------------------------------------------
real %e
user %U
sys %S

The resource specifiers, which are a superset of those recognized by the tcsh(1) builtin `time' command, are:
%      A literal `%'.
E      Elapsed real (wall clock) time used by the process, in [hours:]minutes:seconds.
P      Percentage of the CPU that this job got.  This is just user + system times divided by the total running time. It also prints a percentage sign.
S      Total number of CPU-seconds used by the system on behalf of the process (in kernel mode), in seconds.
U      Total number of CPU-seconds that the process used directly (in user mode), in seconds.
e      Elapsed real (wall clock) time used by the process, in seconds.
---------------------------------------------------------------------------

References:
http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1
http://blog.he96.com/2011/01/linux-timewhat-do-real-user-and-sys.html
http://yuanfarn.blogspot.tw/2012/08/linux-time.html

Use valgrind's callgrind tool to find out the most time consuming function in your application

  1. Use "$ valgrind --tool=callgrind ./APPLICATION ..." to analyze application performance,
     it will generate a callgrind output(ex:callgrind.out.7722) to help you get performance informations:
      $ valgrind --tool=callgrind ./your_application param1 param2 ...
     
  2. Use kcachegrind tool to visualize callgrind output:
      $ sudo apt-get install kcachegrind
      $ kcachegrind callgrind.out.7722
     
  3. REF: http://baptiste-wicht.com/posts/2011/09/profile-c-application-with-callgrind-kcachegrind.html