Skip to content

Instantly share code, notes, and snippets.

View fergiemcdowall's full-sized avatar

Fergus McDowall fergiemcdowall

  • Oslo
View GitHub Profile
@fergiemcdowall
fergiemcdowall / levelUpStressTest.js
Last active December 21, 2015 03:09
A gist that stress tests levelUP by inserting lots of batch files containing JSON. This can be configured to create a "memory leak" in levelUP.
//[email protected]
//A very simple stress test for levelUP
//make lots of LorumIpsum json files, put them into batches, and then
//cram as many of them as possible into LevelUP
//At the time of writing (15 aug 2013) this will create a memory leak
//adjust size of batches here
var totalBatchFiles = 300;
var totalDocsPerBatchFile = 100;
@fergiemcdowall
fergiemcdowall / LevelDBFileReader.js
Last active January 10, 2022 14:56
A Gist to demonstrate writing and reading image files to LevelDB via the node module level up
var levelup = require('levelup')
var fs = require('fs');
var db = levelup('./imagedb')
db.put('name', fs.readFileSync('image.png'), { encoding: 'binary' }, function (err) {
db.get('name', { encoding: 'binary' }, function (err, value) {
fs.writeFile('image-copy.png', value, function (err) {
console.log('image-copy.png saved!');
});
})