OK, I explain here
the wrong code is:
function sendRequest
> 02 if(running > concurrent) return;
> 03 if(running ++ < concurrent && left >0)
> process.nextTick(sendRequest);
>
> http.request(reqOptions, function(res) {
> res.on('end', function() {
> running --;
> 08 if(--left == 0) {
> 09 nextTask()
> 10 }
> process.nextTick(sendRequest)
> });
> });
> }
When the tasks[1] is done, means left <= 0, line 9 will call nextTask
execute tasks[2], and but line 11 is still executed, and line 2 does not
filter the left < 0 and continue send request, so tasks[1] and tasks[2] is
both running, so the tasks[2] display rps just about half of tasks[1].
I modified 2 lines code fixed this issue.
function sendRequest
if(running > concurrent || left <=0) return;
if(running ++ < concurrent) process.nextTick(sendRequest);
}
BTW: you can clone https://github.com/guileen/siege.js , run the example, I
bet you will like it even it is not complete yet.
It's easy to write a benchmark module
siege(__dirname + '/app.js')
.concurrent(100)
.for(10000).times
.get('/')
.post('/')
.attack()
It will automatic listen on a temp unix socket, if you not specify what
port to listen.
The output is colorful and real time.
Because of node.js keep alive the connections I think, I can get correct
benchmark on Mac OSX now, we know that `ab` get wrong result on Mac,
because of OS connections limitations I guess. What ever, I can do
benchmark on Mac now.
In the plan, it will also has the feature to enable cookie, and condtional
GET. maybe not now, maybe you can send a pull request.
siege(__dirname + '/app.js')
.concurrent(100)
.for(10000).times
.withCookie()
.with304()
.post('/login', {username:'username', password: 'password}).for(1).times
.get('/')
.attack()
2012/4/27 mscdex <[email protected]>
> On Apr 26, 12:58 pm, Matt <[email protected]> wrote:
> > Why did you remove the post though? Someone else might make the same
> > mistake - it's always good to keep history of how you fixed it.
>
> +1
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
--
Best regards,
Jason Green
桂林
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en