<commit_before>#pomelo-robot
pomelo-robot is simple tool to benchmark the socket.io server performance.

pomelo-robot can run in multiple mode such as single machine with many process
,distribute test many socket.io server.

pomelo-robot execute developer custom JavaScript in a sand box and static
monitor include max(min,avg) response time and QPS,etc. then report to web http
server with graph display

pomelo-robot also can be used in http benchmark by developer script;  


##Installation
```
npm install pomelo-robot
```

##Usage
``` javascript

var Robot = require('pomelo-robot').Robot;
//developer custom data source with data application
var queryHero = require('./app/data/mysql').queryHero;
//config the master and app,detail by demo 
var config = require('./app/config/config');
var fs = require('fs');

var robot = new Robot(config);

if (robot.server==='master') {
    robot.run(__filename);
} else {
    var mysql =config[robot.env].mysql;
    var Client = require('mysql').Client;
    var client = new Client();
    client.host = mysql.host;
    client.user = mysql.user;
    client.password = <PASSWORD>;
    client.database = mysql.database;
    var args = process.argv;
    var i = 5;
    var limit = args[i++];
    var offset= args[i++];
    //developer execute script
    var script = fs.readFileSync(process.cwd() + '/app/config/lord.js', 'utf8');
    queryHero(client,limit,offset,function(error,users){robot.run(users,script)});
}

``` 

##API
###robot.runMaster()
run master server and http server,then initial server status include
clients,start up file. 
####Arguments
+ startUpFile - The master server auto start up agent file name, default is
  current run file;

###robot.runAgent()
robot run in client agent mode.
####Arguments
+ datasource - The Array data ,and the size is the concurrent users. 
+ script - The developer custom script that agent should be execute. 

###Notice
when pomelo-robot run in distribute mode, every client should be in same
directory path and master could be ssh login automatic. Otherwise developer can
start up agent by self,for the custom script, the demo is attachment.<commit_msg>modify README.md for npm publish<commit_after>#pomelo-robot
pomelo-robot is a simple tool to benchmark the socket.io server's performance.

pomelo-robot can run in multiple mode such as single machine or distributed machines with many processes.

pomelo-robot executes developer's custom javascript in a sand box and statistical analysis monitors including avg(min/max) responsing time and QPS, etc. Then reports data to the http server with graph display.

pomelo-robot can be also used in http benchmark with developer script.


##Installation
```
npm install pomelo-robot
```

##Usage
``` javascript
var envConfig = require('./app/config/env.json');
var config = require('./app/config/' + envConfig.env + '/config');
var Robot = require('pomelo-robot').Robot;

var robot = new Robot(config);
var mode = 'master';

if (process.argv.length > 2){
  mode = process.argv[2];
}

if (mode !== 'master' && mode !== 'client') {
  throw new Error(' mode must be master or client');
}

if (mode === 'master') {
  robot.runMaster(__filename);
} else {
  var script = (process.cwd() + envConfig.script);
  robot.runAgent(script);
}
``` 

##API
###robot.runMaster()
run master server and http server, then init server status including clients with startup file. 
####Arguments
+ startupFile - The master server auto startup agent file name, default is current running file;

###robot.runAgent()
robot run in client agent mode.
####Arguments
+ script - The developer's custom script that the agent will execute. 

###Notice
When pomelo-robot run in distribute mode, every client should be in same directory path and master could be ssh login automatic. Otherwise developer can start up agent manually. For the custom script, refer to [the demo](https://npmjs.org/package/pomelo-robot-demo).

{'fraction_non_alphanumeric': 0.10856269113149847, 'fraction_numerical': 0.0010193679918450561, 'mean_word_length': 4.332880434782608, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4565451', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1110, 'n_words': 455}