Skip to content

Instantly share code, notes, and snippets.

@pofallon
Created June 23, 2012 21:23
Show Gist options
  • Save pofallon/2980063 to your computer and use it in GitHub Desktop.
Save pofallon/2980063 to your computer and use it in GitHub Desktop.
Timed test of BlobReadStream
/* To run this example:
*
* - Save this file as test.js
* - Run 'npm install azure' and 'npm install bluesky'
* - Set the variables 'myAccount' and 'myKey' to your Azure storage credentials
* - Set the 'containerName' and 'blobName' variables to an existing blob in Azure storage
* - Run as 'node test.js'
*
* The BlobReadStream source can be found here:
* https://github.com/pofallon/node-bluesky/blob/master/lib/blobReadStream.js
*
*/
var myAccount = '';
var myKey = '';
var containerName = '';
var blobName = '';
var azure = require('azure');
var blobService = azure.createBlobService(myAccount,myKey);
var BlobReadStream = require('bluesky/lib/blobReadStream');
var readStream = new BlobReadStream();
var d1 = Date.now();
readStream.on('end', function() {
console.log('TEST: End (+' + (Date.now() - d1) + ' ms)');
});
readStream.on('data', function(data) {
console.log('TEST: Data: ' + data + ' (+' + (Date.now() - d1) + ' ms)');
});
console.log('TEST: Calling getBlobToStream (+' + (Date.now() - d1) + ' ms)');
var d1 = Date.now();
blobService.getBlobToStream(containerName, blobName, readStream, function(err, blobResult) {
console.log('TEST: Callback invoked (+' + (Date.now() - d1) + ' ms)');
readStream.ready();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment