<commit_before>/**
 *  Performance tests for removing ojects
 */

var removals = 100;
var rnd = core.util.random();
var myRandom = rnd.getRandom(seed);
var size = 50000;
var collection_name = "remove_test";
var msg = "Hello from remove test";

function testSetup(dbConn) {
    var t = dbConn[collection_name];
    t.drop();
    t.ensureIndex( { num : 1 } );

    for (var i=0; i<size; i++){
        t.save({ num : i, msg : msg });
    }
}

/**
 *   Compares difference of removing objects from a collection if only includes
 *   field that's indexed, vs w/ additional other fields
 *
 * @param dbConn
 */
function testRemoveWithMultiField(dbConn) {

    // remove once XXX fixed
    print("ed/db/remove1.js:testRemoveWithMultiField() - not run - BUG XXX");
    return;

    var results = {};
    var t = dbConn[collection_name];

    testSetup(dbConn);
    
    results.indexOnly = Date.timeFunc(
        function(){
            for (var i = 0; i < removals; i++) {
                t.remove({num : i});
            }

            t.findOne();
        }
    );

    testSetup(dbConn);
    
    results.withAnother = Date.timeFunc(
        function(){
            for (var i = 0; i < removals; i++) {
                t.remove({num : i, msg : msg});
            }

            t.findOne();
        }
    );


     assert(   0.90 < (results.indexOnly / results.withAnother) > 1.10,
            "indexOnly / withAnother (" + results.indexOnly + " / " + results.withAnother + " ) = " +
            results.indexOnly /  results.withAnother + " not in [0.90, 1.10]" );
}

var db = connect( "ed_perf_remove1" );

testRemoveWithMultiField(db);
<commit_msg>add FB BUG # for this test<commit_after>/**
 *  Performance tests for removing ojects
 */

var removals = 100;
var rnd = core.util.random();
var myRandom = rnd.getRandom(seed);
var size = 50000;
var collection_name = "remove_test";
var msg = "Hello from remove test";

function testSetup(dbConn) {
    var t = dbConn[collection_name];
    t.drop();
    t.ensureIndex( { num : 1 } );

    for (var i=0; i<size; i++){
        t.save({ num : i, msg : msg });
    }
}

/**
 *   Compares difference of removing objects from a collection if only includes
 *   field that's indexed, vs w/ additional other fields
 *
 * @param dbConn
 */
function testRemoveWithMultiField(dbConn) {

    // remove once 984 fixed
    print("ed/db/remove1.js:testRemoveWithMultiField() - not run - BUG 984");
    return;

    var results = {};
    var t = dbConn[collection_name];

    testSetup(dbConn);
    
    results.indexOnly = Date.timeFunc(
        function(){
            for (var i = 0; i < removals; i++) {
                t.remove({num : i});
            }

            t.findOne();
        }
    );

    testSetup(dbConn);
    
    results.withAnother = Date.timeFunc(
        function(){
            for (var i = 0; i < removals; i++) {
                t.remove({num : i, msg : msg});
            }

            t.findOne();
        }
    );


     assert(   0.90 < (results.indexOnly / results.withAnother) > 1.10,
            "indexOnly / withAnother (" + results.indexOnly + " / " + results.withAnother + " ) = " +
            results.indexOnly /  results.withAnother + " not in [0.90, 1.10]" );
}

var db = connect( "ed_perf_remove1" );

testRemoveWithMultiField(db);

{'fraction_non_alphanumeric': 0.14069591527987896, 'fraction_numerical': 0.017549167927382755, 'mean_word_length': 2.1396011396011394, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '6863483', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1043, 'n_words': 273}