
好久沒寫文章,復出第一篇竟然是寫這種.... 該振作點了。
關於Linux 關於出走 關於書 關於電影 關於搖滾 有喃喃自語 有不平之鳴
#!/bin/sh
rm test test.lzo test.gz
cp $1 test
lzop -1 test
gzip -1 test -c > test.gz
ls -l test test.lzo test.gz
echo "-----------------------------------------------------------------------"
echo "test"
./eatmem
sleep 10
cat --help >& /dev/null
time cat test > /dev/null
echo "-----------------------------------------------------------------------"
echo "test.lzo"
./eatmem
sleep 10
lzop --help >& /dev/null
time lzop -d test.lzo -c > /dev/null
echo "-----------------------------------------------------------------------"
echo "test.gz"
./eatmem
sleep 10
gunzip --help >& /dev/null
time gunzip test.gz -c > /dev/null
$ cd ~/tmp
$ cp /usr/lib/libamarok.so.0.0.0 .
$ lzop libamarok.so.0.0.0
$ gzip -1 libamarok.so.0.0.0 -c > libamarok.so.0.0.0.gz
$ ls -l libamarok.so.0.0.0*
-rwxr-xr-x 1 ranma users 5492864 2007-01-18 15:57 libamarok.so.0.0.0*
-rw-r--r-- 1 ranma users 2227760 2007-01-18 16:11 libamarok.so.0.0.0.gz
-rwxr-xr-x 1 ranma users 2734159 2007-01-18 15:57 libamarok.so.0.0.0.lzo*
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define MY_RAM_SIZE (1024*1024*1024)
int main()
{
void *p;
printf("Allocating memory\n");
p = malloc(MY_RAM_SIZE);
if (!p)
return -1;
printf("Filling memory\n");
memset(p, 0x55, MY_RAM_SIZE);
printf("Freeing memory\n");
free(p);
return 0;
}
$ ./eatmem ; sleep 10
Allocating memory
Filling memory
Freeing memory
$ time cat libamarok.so.0.0.0 > /dev/null
real 0m2.553s
user 0m0.001s
sys 0m0.038s
$ time lzop -d libamarok.so.0.0.0.lzo -c > /dev/null
real 0m0.448s
user 0m0.088s
sys 0m0.013s
$ time gunzip libamarok.so.0.0.0.gz -c > /dev/null
real 0m0.444s
user 0m0.171s
sys 0m0.006s