magicat
2010年8月25日 星期三
C++ string
若要在string 後面在連接其他字串的方法有三種, 可是效率卻不同,假設要在字串str 後面加其他字串word
#include
string str, word;
方法1:
str += word;
方法2:
str = str.append(word);
方法3:
str = str + word;
效率比較
方法1 = 方法2 > 方法3
方法3會將字串str + word複製到一個記憶體空間,再將記憶體空間內的值指派到str 內, 所以多花了一倍時間
2010年8月18日 星期三
InfiniBand on Redhat/Centos Linux.
## install necessary packages
yum install ibutils.x86_64 openib.noarch opensm.x86_64 infiniband-diags.x86_64
## client
yum install ibutils.x86_64 openib.noarch infiniband-diags.x86_64
## start services
service openibd start
service opensmd start
## configure interface
DEVICE=ib0
TYPE=Infiniband
BOOTPROTO=static
BROADCAST=192.168.0.255
IPADDR=192.168.0.1
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.ib0.arp_ignore=1
net.ipv4.conf.ib1.arp_ignore=1
references:
HOWTO: Getting Started with InfiniBand on Redhat/Centos Linux.
2010年8月17日 星期二
How to suspend process
今天有人問我在Linux 下要如何將行程暫停, 這個問題我從來沒想過. 用Google 查了一下發現用kill 就行了.
kill -stop PID #suspend process
kill -cont PID #restart process
2010年8月11日 星期三
How to query dependencies from RPM file or packages
rpm -qpR {.rpm-file}
rpm -qR {package-name}
How to list packages in Ubuntu
dpkg --get-selections > packages
References:
http://www.cyberciti.biz/faq/how-do-i-find-what-dependencies-a-rpm-file-has/
http://askubuntu.com/questions/17823/how-to-list-all-installed-packages
2010年7月28日 星期三
swap two variable
For Interger
x ^= y;
y ^= x;
x ^= y;
For Float number
x=x+y;
y=x-y;
x=x-y;
較新的文章
較舊的文章
首頁
訂閱:
文章 (Atom)