<commit_before>'use strict';

const { Suite } = require('./helpers');
const { config, data } = require('./fixtures/data.json');
const { DataFrame } = require('./src');

const run = async () => {
    const suite = Suite('Search');

    const dataFrame = DataFrame.fromJSON(config, data);
    suite.add('using query: "age:<20"', {
        fn() {
            dataFrame.search('age:<20');
        }
    });

    suite.add('using query: "age:>80 AND alive:false"', {
        fn() {
            dataFrame.search('age:>80 AND alive:false');
        }
    });

    return suite.run({
        async: true,
        initCount: 2,
        minSamples: 2,
        maxTime: 20,
    });
};
if (require.main === module) {
    run().then((suite) => {
        suite.on('complete', () => {});
    });
} else {
    module.exports = run;
}<commit_msg>Improve data frame search benchmark<commit_after>'use strict';

const { Suite } = require('./helpers');
const { config, data } = require('./fixtures/data.json');
const { DataFrame } = require('./src');

const run = async () => {
    const suite = Suite('Search');

    const dataFrame = DataFrame.fromJSON(config, data);
    suite.add('using query: "age:<20"', {
        fn() {
            dataFrame.search('age:<20');
        }
    });

    suite.add('using query: "age:>80 AND alive:false"', {
        fn() {
            dataFrame.search('age:>80 AND alive:false');
        }
    });

    suite.add('using query: "birthday:>=\\"1990-01-04T00:00:00.000Z\\" AND alive:true"', {
        fn() {
            dataFrame.search('birthday:>="1990-01-04T00:00:00.000Z" AND alive:true');
        }
    });

    suite.add('using query: "ip:\\"192.168.127.12/24\\"', {
        fn() {
            dataFrame.search('ip:"192.168.127.12/24"');
        }
    });

    suite.add('using query: "location:geoDistance(point: "33, 26", distance:1000mi)"', {
        fn() {
            dataFrame.search('location:geoDistance(point: "33, 26", distance:1000mi)');
        }
    });

    suite.add('using query: "metadata.number_of_friends:>5"', {
        fn() {
            dataFrame.search('metadata.number_of_friends:>5');
        }
    });

    return suite.run({
        async: true,
        initCount: 2,
        minSamples: 2,
        maxTime: 20,
    });
};
if (require.main === module) {
    run().then((suite) => {
        suite.on('complete', () => {});
    });
} else {
    module.exports = run;
}
{'fraction_non_alphanumeric': 0.20099461251554082, 'fraction_numerical': 0.042271031910484876, 'mean_word_length': 2.275440976933514, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6883277', 'n_tokens_mistral': 865, 'n_tokens_neox': 783, 'n_words': 142}