Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NodeJS stdlib Post
'use strict';
var url = require('url');
var creds = require('./creds.js');
var https = require('https');
var scheme = 'https';
var hostname = 'api.tempo-db.com';
var baseUrl = scheme + '://' + hostname;
var auth = 'Basic ' + new Buffer(creds.key + ':' + creds.secret).toString('base64');
var seriesKey = '1_D90343085872CA9C_687_0_2000';
function uploadEntry(cb){
var data = [];
data.push({t: new Date(), v: Math.random() * 50});
var body = JSON.stringify(data);
var headers = {
Authorization: auth,
'Content-Type': 'application/json',
'Content-Length': body.length
};
var opts = {
host: hostname,
port: 443,
path: '/v1/series/key/' + seriesKey + '/data/',
method: 'POST',
agent: false,
headers: headers
};
// console.log('sending', data[0]);
var req = https.request(opts,cb);
req.on('error', function(e) {
console.err('error', e);
});
req.write(body);
req.end();
};
function callback(result){
console.log('statusCode', result.statusCode);
}
setInterval(uploadEntry.bind(null, callback), 1000);
setInterval(gc, 1000);
@wolfeidau

This comment has been minimized.

Copy link
Owner Author

commented Oct 9, 2013

This is a summary of allocated objects in master.

     362e703b3e1       10        1 Object: path
     362e703c769       11        0 SecureContext
     362e703c5c1       11        8 Object: agent, keepAlive, headers, ...
     362e70425a9       11       19 WritableState: highWaterMark, ...
     362e70524e1       12        2 Error: stack, name
     362e703c6d1       12        9 Object: rejectUnauthorized, servername, ...
     362e703b329       12       13 Agent: domain, _events, _maxListeners, ...
     362e7041db9       12       21 ReadableState: highWaterMark, buffer, ...
     362e705e921       13        1 Arguments: length
     fdf67166439       13        6 Object: sentConnectionHeader, ...
     362e7040c91       15        8 Array
     362e704cd11       20        7 Array
     362e7006a61       24        0
     362e7040cb1       26        6 Array
     362e7004de9       32        2 Object: callback, domain
     a72cab15f29       35        4 Object: value, enumerable, writable, ...
     362e7040769       36        1 Object: filename
     362e7040789       36        5 Array
     362e7016bb1       37        1 Object: constructor
     362e7004501       37        4 NativeModule: filename, id, exports, ...
     362e7016b29       41        3 Array
     a72cab10d09       54       12 PropertyDescriptor: value_, hasValue_, ...
     362e704ec91       63        4 Array
     362e70046b9      112        2 Array
     362e705e789      138        2 Arguments: length, callee
     362e703b5d9      217        0 Array
     362e7014d21      233        1 Array
     362e70043f9      614        0 Object
@wolfeidau

This comment has been minimized.

Copy link
Owner Author

commented Oct 9, 2013

As requested.

> ::load /home/markw/x64_v8.so
V8 version: 3.20.17.14
Autoconfigured V8 support from target
> 362e7006a61::v8print
362e7006a61 JSObject {
    362e7006a61 JSReceiver {
        362e7006a61 HeapObject < Object  {
            362e7006a60 map = a72cab051e1 (Map)
        }
    }
    362e7006a68 properties = 12303bf04139 (FixedArray)
    362e7006a70 elements = 362e7006a79 (FixedArray)
}
>
@wolfeidau

This comment has been minimized.

Copy link
Owner Author

commented Oct 9, 2013

This is master without the GC routine.

    2818f234f1d1       15        5 Array
    2818f2306a61       24        0
     d882e60f5b1       37        4 NativeModule: filename, id, exports, ...
    277956007409      563        5 TCP: writeQueueSize, owner, onread, ...
    277956009a11      564        6 Object: headers, statusCode, ...
    27795600c779      564        9 Object: subject, issuer, subjectaltname, ...
     d882e61d9c9      565        2 Buffer: length, parent
    27795600cd41      565        3 Object: C, O, CN
    277956007611      565        3 Object: callback, family, oncomplete
    277956007329      565        3 Object: port, host, localAddress
    277956007fe9      565        6 Object: sentConnectionHeader, ...
    27795600ced9      565        6 Object: serialNumber, C, ST, L, O, CN
    277956004ab9      565        7 Object: host, port, path, method, ...
    277956004461      566        6 Object: host, port, path, method, agent, ...
    277956004591      566        7 Object: agent, keepAlive, headers, ...
    27795600e4a9      568        2 Object: t, v
    277956004639     1131        6 Array
    277956004b61     1132        7 Array
    2212d9698cf1     1133        3 Object: oncomplete, bytes, cb
    1492e1289791     1142        1 NativeBuffer: length
     6fc56c967b9     1257       25 IncomingMessage: _readableState, ...
     6bdc9104461     1258        1 Object: free
     5c87182ad61     1258        3 TLSWrap: onhandshakestart, ...
     e920a6099a9     1258       19 WritableState: highWaterMark, ...
     5c87182acf9     1258       29 ClientRequest: domain, _events, ...
     6bdc9104479     1259        1 Object: path
     5c87189f869     1259        5 Object: end, connect, free, close, ...
     5c87182b449     1259        8 Object: agent, keepAlive, headers, ...
     e920a646271     1259       35 TLSSocket: _connecting, _hadError, ...
     e920a609a91     1260        1 Credentials: context
     7bdce6e3a81     1260        9 Object: rejectUnauthorized, servername, ...
     e920a646231     1261        5 Object: credentials, isServer, ...
     5c8718a5fe1     1261       13 Agent: domain, _events, _maxListeners, ...
     d882e607841     1293        6 Object: end, error, connect, free, ...
     5c87189f899     2386        8 Array
     5c87189f7a9     2515       21 ReadableState: highWaterMark, buffer, ...
     7bdce653751     2660        0 SecureContext
    27795600a5c1     2817        1 Arguments: length
    277956004eb9     2840        3 Array
    2779560078a9     3946        2 Object: callback, domain
    277956007c69     5650        4 Array
     d882e606f41     7889        2 Arguments: length, callee
     5c8718c0919     8797        2 Array
     5c8718bc4a9     9264        1 Array
     5c87182aec1    17270        0 Object
     5c87182aed9    17466        0 Array
          OBJECT #OBJECTS   #PROPS CONSTRUCTOR: PROPS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.