<commit_before>var test = require('tap').test,
    OffsetBuffer = require('offset-buffer'),
    BufferGroup = require('../buffer-group.js')(OffsetBuffer, console);

process.on('uncaughtException', function(err) {
    console.log('Uncaught exception: ' + err);
    process.exit(-1);
});

var i, m = 50000,
    time_start = Date.now(),
    duration,
    group = new BufferGroup(),
    extract1, extract2;

for (i = 0; i < m; i++) {
    group.push(new Buffer([0x01, 0x02, 0x03]));
    group.push(new Buffer([0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d]));
    group.push(new Buffer([0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18]));
    extract1 = group.extract(4);
    extract2 = group.extract(group.length);
}
duration = Date.now() - time_start;
console.log('BufferGroup.extract(): ' + (m / (duration / 1000)).toFixed(2) + ' ops/sec');
<commit_msg>added benchmark for clear<commit_after>var test = require('tap').test,
    OffsetBuffer = require('offset-buffer'),
    BufferGroup = require('../buffer-group.js')(OffsetBuffer, console);

process.on('uncaughtException', function(err) {
    console.log('Uncaught exception: ' + err);
    process.exit(-1);
});

var i, m = 50000,
    time_start = Date.now(),
    duration,
    group = new BufferGroup(),
    extract1, extract2;

for (i = 0; i < m; i++) {
    group.push(new Buffer([0x01, 0x02, 0x03]));
    group.push(new Buffer([0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d]));
    group.push(new Buffer([0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18]));
    extract1 = group.extract(4);
    extract2 = group.extract(group.length);
}
duration = Date.now() - time_start;
console.log('BufferGroup.extract(): ' + (m / (duration / 1000)).toFixed(2) + ' ops/sec');

time_start = Date.now();
for (i = 0; i < m; i++) {
    group.push(new Buffer([0x01, 0x02, 0x03]));
    group.push(new Buffer([0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d]));
    group.push(new Buffer([0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x18]));
    group.clear();
}
duration = Date.now() - time_start;
console.log('BufferGroup.clear(): ' + (m / (duration / 1000)).toFixed(2) + ' ops/sec');


{'fraction_non_alphanumeric': 0.18804985337243402, 'fraction_numerical': 0.17412023460410558, 'mean_word_length': 4.139359698681733, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6171736', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1263, 'n_words': 276}