Skip to content

Instantly share code, notes, and snippets.

@ar2rsawseen
Created September 14, 2015 07:29
Show Gist options
  • Select an option

  • Save ar2rsawseen/8838c50bf8692d28b8ab to your computer and use it in GitHub Desktop.

Select an option

Save ar2rsawseen/8838c50bf8692d28b8ab to your computer and use it in GitHub Desktop.

Revisions

  1. ar2rsawseen created this gist Sep 14, 2015.
    29 changes: 29 additions & 0 deletions generateRequests.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    var request = require('request');

    function makeRequest(cnt){
    var options = {
    uri: 'http://localhost/i?app_key=ccab3e6e1b5ca7b42fc2194b57358b115edb45fc&device_id='+Math.random()+'&begin_session=1&events=[{%22key%22:%22click%22,%22count%22:1,%22segmentation%22:{%22message%22:%22a%22}},{%22key%22:%22go%22,%22count%22:1,%22segmentation%22:{%22message%22:%22b%22}},{%22key%22:%22do%22,%22count%22:1,%22segmentation%22:{%22message%22:%22c%22}}]',
    method: 'GET'
    };
    request(options, function (error, response, body) {
    if(!error){
    try{
    var arr = JSON.parse(body);
    console.log(cnt, arr);
    }
    catch(ex){}
    }
    });
    }

    function iterateRequest(){
    makeRequest(1);
    setTimeout(iterateRequest, 1000);
    }
    /*
    for(var i = 0; i < 100000; i++){
    makeRequest(i);
    }
    */

    iterateRequest();