C/C++

Gprof for Benchmarking C and C++ code

First, you compile the program using "-pg" option:

$ gcc -pg -o a.out test.cc

or 

$ g++ -pg -o a.out test.cpp

Then run the program:

$ a.out

This will generate a file "gmon.out". We will use gprof to view it:

$ gprof a.out gmon.out

Read the man page of gprof to understand the output.

CDB Compilation Error: "mismatches non-TLS reference in cdb.a"

I tried to compile cdb-0.75 on CentOS, and got the following error:

cdb-0.75$ make
./load cdbget cdb.a buffer.a unix.a byte.a
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in cdb.a(cdb.o)
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [cdbget] Error 1

Rotating Algorithms from 'Programming Pearls' by Jon Bentley

Orginal: http://ailab.kangwon.ac.kr/?module=file&act=procFileDownload&file_srl=22...

/* Copyright (C) 1999 Lucent Technologies */
/* From 'Programming Pearls' by Jon Bentley */ 
/* rotate.c -- time algorithms for rotating a vector

      Input lines:
             algnum numtests n rotdist

             algnum: