Mortgage Find Mortgage Home Mortgages Find Mortgage Home Mortgages

Blem Remortgage Findmortgagehomemortgages Home Ro Zh Cn Xinlongblog Xinlongzatan Find Mortgage Home Mortgages MK2 - 博客园

Blem Remortgage Findmortgagehomemortgages Home Ro Zh Cn Xinlongblog Xinlongzatan Find Mortgage Home Mortgages

 Xinlongblog Owww.ddaa66.comTsearch/www.aaaqe.comosearch searchTDdaa66.comP Remortgage 1search1searchrsearchn Remortgage Hosearcht Findmortgagehomemortgages   Home o Home . Xinlongzatan xmsear Remortgage hl Be  Blem s Remortgage ac Remortgage o Xinlongzatan   Blem i Xinlongblog losearchgz Xinlongzatan t Blem nsearchr Xinlongblog ewww.aaaqe.comr Findmortgagehomemortgages h Findmortgagehomemortgages  Blsearchm  Xinlongzatan seawww.aaaqe.comc Blem nsearchBlesearch  Xinlongblog t Home LesearchgsearchhDdaa66.com  Remortgage \\www.ddaa66.com
 Findmortgagehomemortgages onsearchcsearchisearchn Blem ke Xinlongzatan p Remortgage a Home ie Findmortgagehomemortgages r\nAcep Xinlongblog :searche Home tsearchhtsearchlsearcha Remortgage p Xinlongzatan iai Home n Xinlongzatan xt Xinlongzatan lx Home l, Blem p Xinlongblog li Blem a Findmortgagehomemortgages iwww.aaaqe.comn Home x Xinlongblog lqwww.ddaa66.com0. Xinlongzatan , Blem /*q=search.8 Findmortgagehomemortgages r\www.aaaqe.com
C Xinlongzatan o Findmortgagehomemortgages i Xinlongblog :searchon Remortgage ec Home .searchid Findmortgagehomemortgages OY2n Home G Blem I3 Blem bsearch5Ddaa66.comY Xinlongzatan e Home J Xinlongblog Tjf Remortgage F Xinlongzatan tbY1 Findmortgagehomemortgages z Xinlongblog Ng Xinlongblog 5 Xinlongblog oJv3M Home et Xinlongblog 5 Blem Twww.ddaa66.comrfw Remortgage CkRwww.ddaa66.com% Remortgage F Xinlongzatan XUksearchr\search
searchsDdaa66.comr Xinlongblog Awww.ddaa66.coment Home Msearchzsearchl Blem a/5 Remortgage 0 searchM Remortgage cn Blem ossearch; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.41 Safari/535.7
\r\n\r\n
q=bar

需求

获取Header中Host的值

Buffer版本

var SPACE = 0x20, // ' '
 COLON = 0x3a, // 58, :
 NEWLINE = 0x0a, // \n
 ENTER = 0x0d; // \r

exports.parse = function parse(data) {}
 i++;
 }
 }
 } else if(data[i] === ENTER && data[i+1] === NEWLINE) {}
 }
 }
 return null;
};

String版本

exports.parse = function parse(data) {}
 host = cut[1].trim().toLowerCase();
 return host;
 }
 }
 return null;
};

测试脚本

var buffer_parse = require('./string-buffer-benchmark-parse-header-buffer').parse
 , string_parse = require('./string-buffer-benchmark-parse-header-string').parse;

var data = new Buffer('POST /foo HTTP/1.1\r\nHost: foo.example.com\r\nContent-Length: 5\r\nConnection:keep-alive\r\nAccept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nCookie:connect.sid=OY2nKGqI3obs5lYee0JKTjhf.FDtbY1Jz5Ngw5So9Jv3MUetI5ITvrIfwgCkRw%2FcXUCk\r\nUser-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.41 Safari/535.7\r\n\r\nq=bar');

//console.log(buffer_parse(data));
//console.log(string_parse(data), data.length);

var n = 1000000;
var start = new Date();
for(var i = 0; i < n; i++) {}
console.log('buffer_parse take: ' + (new Date() - start) + ' ms');

start = new Date();
for(var i = 0; i < n; i++) {}
console.log('string_parse take: ' + (new Date() - start) + ' ms');

测试结果

$ node string-buffer-benchmark.js
buffer_parse take: 1888 ms
string_parse take: 4948 ms

结论

Buffer比String快多了。

posted @ 2011-11-19 01:21 MK2 阅读(350) 评论(0) 编辑
2011年11月17日
Nodejs "Hello world" benchmark

新版本 nodejs 性能

node0.6.0 已经发布了,性能提高如何呢?
本文将记录 nodejs 历史更新中所有版本的hello world性能测试。

测试环境

$ uname -a
Linux xxx 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

$ cat /proc/cpuinfo
Intel(R) Xeon(R) CPU E5410 @ 2.33GHz

测试 helloworld.js

var http = require('http');
http.createServer(function (req, res) {});
 res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at ');

http_load 压测命令

$ http_load -p 100 -s 10 

测试结果: fetches/sec

0.7.0
7676
0.6.70.6.60.6.50.6.40.6.30.6.20.6.10.6.0
77918046806081118070813882408157
0.5.100.5.90.5.80.5.70.5.6 0.5.50.5.40.5.30.5.20.5.10.5.0
82007259707170986996 8073-79318127--
0.4.120.4.110.4.100.4.90.4.8 0.4.70.4.60.4.50.4.4 0.4.30.4.20.4.10.4.0
75107558760076066588 7916793179607981 7930796579757490
0.3.80.3.70.3.60.3.50.3.4 0.3.30.3.20.3.10.3.0
78107871781588809000 899992009347-
0.2.60.2.50.2.40.2.3 0.2.20.2.10.2.0
7525748174897500 741071367130
0.1.1040.1.1030.1.1020.1.1010.1.100 0.1.990.1.980.1.970.1.960.1.95 0.1.940.1.930.1.920.1.910.1.90 0.1.0
76407538753776747040 72807211734072707210 70637931802085618146 -

v0.6.0与v0.4.12的性能对比

v0.6.0更新 说明文章中,列出的对比数据

v0.4.12 (linux) v0.6.0 (linux)

http_simple.js /bytes/1024 5461 r/s 6263 r/s
io.js read  19.75 mB/s 26.63 mB/s
io.js write 21.60 mB/s 17.40 mB/s
startup.js  74.7 ms 49.6 ms

v0.4.12 (windows: Cygwin) v0.6.0 (windows)

http_simple.js /bytes/1024 3858 r/s 5823 r/s
io.js read  12.41 mB/s 26.51 mB/s
io.js write 12.61 mB/s 33.58 mB/s
startup.js  152.81 ms  52.04 ms

v0.4 和 v0.6之间的更新说明请查看: API-changes-between-v0.4-and-v0.6

node0.7.0

7675.8 fetches/sec, 92109.6 bytes/sec
msecs/connect: 0.050985 mean, 1.047 max, 0.02 min
msecs/first-response: 12.9343 mean, 47.329 max, 2.926 min

node0.6.7

7790.79 fetches/sec, 93489.5 bytes/sec
msecs/connect: 0.052154 mean, 0.716 max, 0.023 min
msecs/first-response: 12.7397 mean, 41.609 max, 5.318 min

node0.6.6

8046.29 fetches/sec, 96555.5 bytes/sec
msecs/connect: 0.0517639 mean, 0.396 max, 0.023 min
msecs/first-response: 12.3359 mean, 36.495 max, 4.808 min

node0.6.5

8060.28 fetches/sec, 96723.4 bytes/sec
msecs/connect: 0.0518643 mean, 0.702 max, 0.021 min
msecs/first-response: 12.3109 mean, 35.02 max, 4.762 min

node0.6.4

8111 fetches/sec, 97332 bytes/sec
msecs/connect: 0.051521 mean, 1.847 max, 0.021 min
msecs/first-response: 12.2351 mean, 49.227 max, 1.847 min

node0.6.3

8070 fetches/sec, 96840 bytes/sec
msecs/connect: 0.0517654 mean, 0.502 max, 0.02 min
msecs/first-response: 12.2967 mean, 51.886 max, 5.151 min

node0.6.2

8137.79 fetches/sec, 97653.5 bytes/sec
msecs/connect: 0.0515829 mean, 0.642 max, 0.021 min
msecs/first-response: 12.1961 mean, 42.128 max, 3.111 min

node0.6.1

8239.6 fetches/sec, 98875.2 bytes/sec
msecs/connect: 0.0530447 mean, 0.439 max, 0.022 min
msecs/first-response: 12.0422 mean, 32.93 max, 1.846 min

node0.6.0

8157.38 fetches/sec, 97888.5 bytes/sec
msecs/connect: 0.0512865 mean, 0.741 max, 0.022 min
msecs/first-response: 12.1661 mean, 46.023 max, 4.57 min

node0.5.10

8200 fetches/sec, 98400 bytes/sec
msecs/connect: 0.0517871 mean, 0.508 max, 0.024 min
msecs/first-response: 12.0963 mean, 34.816 max, 4.831 min

node0.5.9

7258.88 fetches/sec, 87106.6 bytes/sec
msecs/connect: 0.0521661 mean, 0.667 max, 0.022 min
msecs/first-response: 13.6817 mean, 49.23 max, 3.31 min

node0.5.8

7070.8 fetches/sec, 84849.6 bytes/sec
msecs/connect: 0.0523142 mean, 0.517 max, 0.022 min
msecs/first-response: 14.0466 mean, 39.545 max, 6.215 min

node0.5.7

7097.59 fetches/sec, 85171.1 bytes/sec
msecs/connect: 0.0526457 mean, 0.586 max, 0.024 min
msecs/first-response: 13.9935 mean, 44.333 max, 5.604 min

node0.5.6

6995.6 fetches/sec, 83947.2 bytes/sec
msecs/connect: 0.0525126 mean, 0.413 max, 0.022 min
msecs/first-response: 14.1971 mean, 37.55 max, 6.123 min

node0.5.5

8073.3 fetches/sec, 96879.6 bytes/sec
msecs/connect: 0.0509257 mean, 0.41 max, 0.02 min
msecs/first-response: 12.2924 mean, 44.222 max, 4.323 min

node0.5.4

出现编译错误:

/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/home/admin/pkgs/node-v0.5.4/build/default/deps/uv/uv.a(eio.o): In function `eio__sync_file_range':
/home/admin/pkgs/node-v0.5.4/build/default/deps/uv/src/eio/eio.c:1083: undefined reference to `sync_file_range'
collect2: ld returned 1 exit status
Waf: Leaving directory `/home/admin/pkgs/node-v0.5.4/build'
Build failed: -> task failed (err #1): 
 {}
make: *** [program] Error 1

node0.5.3

7931.39 fetches/sec, 95176.7 bytes/sec
msecs/connect: 0.0520728 mean, 0.701 max, 0.024 min
msecs/first-response: 12.5109 mean, 45.553 max, 5.302 min

node0.5.2

8126.8 fetches/sec, 97521.6 bytes/sec
msecs/connect: 0.0513291 mean, 2.476 max, 0.021 min
msecs/first-response: 12.2076 mean, 38.541 max, 1.328 min

node0.5.1

编译不通过,暂缺

node0.5.0

编译不通过,暂缺

node0.4.12

7510 fetches/sec, 90120 bytes/sec
msecs/connect: 0.0540341 mean, 0.631 max, 0.023 min
msecs/first-response: 13.2113 mean, 47.364 max, 3.807 min

node0.4.11

7557.79 fetches/sec, 90693.5 bytes/sec
msecs/connect: 0.0553164 mean, 0.467 max, 0.025 min
msecs/first-response: 13.13 mean, 44.789 max, 2.899 min

node0.4.10

7600 fetches/sec, 91200 bytes/sec
msecs/connect: 0.0534043 mean, 0.367 max, 0.022 min
msecs/first-response: 13.0584 mean, 53.123 max, 4.559 min

node0.4.9

7605.7 fetches/sec, 91268.4 bytes/sec
msecs/connect: 0.0539834 mean, 0.379 max, 0.02 min
msecs/first-response: 13.0469 mean, 46.833 max, 5.299 min

node0.4.8

6587.9 fetches/sec, 79054.8 bytes/sec
msecs/connect: 0.0512022 mean, 0.499 max, 0.021 min
msecs/first-response: 15.0846 mean, 49.04 max, 4.448 min

node0.4.7

7916.1 fetches/sec, 94993.2 bytes/sec
msecs/connect: 0.0516686 mean, 1.629 max, 0.021 min
msecs/first-response: 12.5375 mean, 43.116 max, 5.695 min

node0.4.6

7930.88 fetches/sec, 95170.6 bytes/sec
msecs/connect: 0.0517224 mean, 0.704 max, 0.022 min
msecs/first-response: 12.5125 mean, 42.465 max, 5.519 min

node0.4.5

7960 fetches/sec, 95520 bytes/sec
msecs/connect: 0.0522368 mean, 0.674 max, 0.021 min
msecs/first-response: 12.4676 mean, 43.185 max, 5.598 min

node0.4.4

7981.4 fetches/sec, 95776.8 bytes/sec
msecs/connect: 0.0511981 mean, 0.729 max, 0.02 min
msecs/first-response: 12.4255 mean, 51.829 max, 5.506 min

node0.4.3

7929.9 fetches/sec, 95158.8 bytes/sec
msecs/connect: 0.0510949 mean, 0.833 max, 0.023 min
msecs/first-response: 12.5189 mean, 51.677 max, 5.02 min

node0.4.2

wBlem Remortgage Findmortgagehomemortgages Home Ro Zh Cn Xinlongblog Xinlongzatan Find Mortgage Home Mortgages MK2 - 博客园o s Find Mortgage Home Mortgages wBlem Remortgage Findmortgagehomemortgages Home Ro Zh Cn Xinlongblog Xinlongzatan Find Mortgage Home Mortgages MK2 - 博客园a Find Mortgage Home Mortgages Find