2009年11月17日 星期二

Performance of Python

http://groups.google.com/group/unladen-swallow/browse_thread/thread/4edbc406f544643e?pli=1


google已經對python的performance感到不能接受了,所以 unlader-swallow project打算增加python的performance 達到5倍以上。


這一份report道盡了google的不爽..


http://code.google.com/p/unladen-swallow/downloads/detail?name=Unladen_Swallow_PyCon.pdf&can=2&q=


2009年11月3日 星期二

Linux From Scratch in QEMU CH. 2

Chapter 2. Preparing a New Partition

http://www.linuxfromscratch.org/lfs/view/stable/chapter02/creatingpartition.html

這一個章節需要使用一個新的硬碟,但是我也實在生不出來,想想既然是個練習,就把這個linux 安裝在一個disk image 上吧。

先看這一篇文章來建立一個qemu disk image
http://en.wikibooks.org/wiki/QEMU/Images

qemu-img create -f raw maindisk.img 3G
qemu-img create -f raw temp.img 500M


順便使用 ls -lhsS 看了一下檔案大小以及所佔用的磁碟空間:

total 0
0 -rw-r--r-- 1 tim tim 3.0G 2009-11-04 11:17 maindisk.img
0 -rw-r--r-- 1 tim tim 500M 2009-11-04 10:20 temp.img

這樣看來使用 qemu-img 比 dd 好的地方是可以利用到sparse file 的特性,不只建立迅速,佔用空間也非常小。

mke2fs -jv maindisk.img
sudo mount -o loop maindisk.img /mnt/

建立File system 以及mount 起來,檢查看看剛剛建立的image是不是可以自由存取了。

debugfs -R feature maindisk.img

dbugfs 可以讓這個image更是無所遁形。


也因為使用了 sparse file 的 image ,在經過mke2fs 之後,我們可以使用ls -lasSh 觀察檔案大小來了解file system到底會佔用多少空間:


total 114M
114M -rw-r--r-- 1 tim tim 3.0G 2009-11-04 11:25 maindisk.img
0 -rw-r--r-- 1 tim tim 500M 2009-11-04 10:20 temp.img


maindisk.img 上的ext3 file system 有 114M/3G = 0.037 ,3.7% 的空間耗損。就比例來看,應該算是很小吧。

接下來向Chapter 3 邁進吧。

2009年11月2日 星期一

Linux 博大精深。

剛進去新的部門,同事問我對linux 熟不熟。linux博大精深,我要怎麼回呢?
只是想到我剛剛連cp這個指令也要man一下,我想我永遠也不會說自已對linux 很熟吧!

ps. 剛剛 man 了 cp, 發現 cp -ax 這兩個option在備份以及以root身份幫一般user copy 檔案時還滿有用的,

2009年11月1日 星期日

The effect of pre compiled header in gcc

每次使用C++ , 為了擺脫漫長無盡的 compilation time. 我不得不看一下 precompiled header..

[pre.h]
#include<tr1/unordered_map>
#include<tr1/unordered_set>
#include<tr1/regex>
#include"iostream"
#include"algorithm"
#include"string"
#include"vector"
#include"fstream"



[main.cpp]
#include"pre.h"
using namespace std;
using namespace tr1;
int main(){
vector<int> v;
string s = "tim";
unordered_map<int,int> um;
cout<<"yes"<<endl;
return 0;
}




只要g++ pre.h 就可以產出 pre.h.gch
以後gcc 會優先使用 pre.h.gch.

[Result of benchmark by time:]

Without precompiled header.
real 0m0.370s
user 0m0.336s
sys 0m0.036s


With precompiled header.
real 0m0.120s
user 0m0.088s
sys 0m0.036s

看來可以省一半以上的時間!  
以後在更大的project 再來測測看