<commit_before>var Pbf = require('../'),
    Benchmark = require('benchmark'),
    fs = require('fs');

var protobuf = require('protocol-buffers'),
    messages = protobuf(fs.readFileSync('../vector-tile-js/proto/vector_tile.proto'));

var suite = new Benchmark.Suite(),
    data = fs.readFileSync(__dirname + '/fixtures/12665.vector.pbf');

suite
.add('decode vector tile with pbf', function() {
    new Pbf(data).readFields(readTile, []);
})
.add('decode vector tile with protocol-buffers', function() {
    messages.tile.decode(data);<commit_msg>add JSON.parse to benchmarks for comparison<commit_after>var Pbf = require('../'),
    Benchmark = require('benchmark'),
    fs = require('fs');

var protobuf = require('protocol-buffers'),
    messages = protobuf(fs.readFileSync('../vector-tile-js/proto/vector_tile.proto'));

var suite = new Benchmark.Suite(),
    data = fs.readFileSync(__dirname + '/fixtures/12665.vector.pbf');

var layers = new Pbf(data).readFields(readTile, []);
var layersJSON = JSON.stringify(layers);

suite
.add('decode vector tile with pbf', function() {
    new Pbf(data).readFields(readTile, []);
})
.add('native JSON.parse of the same data', function() {
    JSON.parse(layersJSON);
})
.add('decode vector tile with protocol-buffers', function() {
    messages.tile.decode(data);
{'fraction_non_alphanumeric': 0.1732824427480916, 'fraction_numerical': 0.007633587786259542, 'mean_word_length': 4.626609442060086, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7006391', 'n_tokens_mistral': 418, 'n_tokens_neox': 408, 'n_words': 89}