benchmark/smallbank/mixed.js
/**
 * Generates small bank workload with specified number of accounts
 * and operations.
 * @returns {Object} array of json objects and each denotes
 * one operations
 **/
Generates small bank workload with specified number of accounts
and operations.
@returns {Object} array of json objects and each denotes
one operations
Generates small bank workload with specified number of accounts and operations . @returns { Object } array of json objects and each denotes one operations
function generateWorkload() {
    let workload = [];
    for(let j= 0; j<txnPerBatch; j++) {
        let op_index =  Math.floor(Math.random() * Math.floor(operation_type.length));
        let acc_index = getAccount();
        let random_op = operation_type[op_index];
        let random_acc = account_array[acc_index];
        let amount = Math.floor(Math.random() * 200);
        let op_payload;
        switch(random_op) {
        case 'transact_savings': {
            op_payload = {
                'amount': amount,
                'customer_id': random_acc,
                'transaction_type':random_op
            };
            break;
        }
        case 'deposit_checking': {
            op_payload = {
                'amount': amount,
                'customer_id': random_acc,
                'transaction_type':random_op
            };
            break;
        }
        case 'send_payment': {
            let accounts = get2Accounts();
            op_payload = {
                'amount': amount,
                'dest_customer_id': account_array[accounts[0]],
                'source_customer_id': account_array[accounts[1]],
                'transaction_type': random_op
            };
            break;
        }
        case 'write_check': {
            op_payload = {
                'amount': amount,
                'customer_id': random_acc,
                'transaction_type':random_op
            };
            break;
        }
        case 'amalgamate': {
            let accounts = get2Accounts();
            op_payload = {
                'dest_customer_id': account_array[accounts[0]],
                'source_customer_id': account_array[accounts[1]],
                'transaction_type': random_op
            };
            break;
        }
        default: {
            throw new Error('Invalid operation!!!');
        }
        }
        workload.push(op_payload);
    }
    return workload;
}
function generateWorkload ( ) { let workload = [ ] ; for ( let j = 0 ; j < txnPerBatch ; j ++ ) { let op_index = Math . floor ( Math . random ( ) * Math . floor ( operation_type . length ) ) ; let acc_index = getAccount ( ) ; let random_op = operation_type [ op_index ] ; let random_acc = account_array [ acc_index ] ; let amount = Math . floor ( Math . random ( ) * 200 ) ; let op_payload ; switch ( random_op ) { case 'transact_savings' : { op_payload = { 'amount' : amount , 'customer_id' : random_acc , 'transaction_type' : random_op } ; break ; } case 'deposit_checking' : { op_payload = { 'amount' : amount , 'customer_id' : random_acc , 'transaction_type' : random_op } ; break ; } case 'send_payment' : { let accounts = get2Accounts ( ) ; op_payload = { 'amount' : amount , 'dest_customer_id' : account_array [ accounts [ 0 ] ] , 'source_customer_id' : account_array [ accounts [ 1 ] ] , 'transaction_type' : random_op } ; break ; } case 'write_check' : { op_payload = { 'amount' : amount , 'customer_id' : random_acc , 'transaction_type' : random_op } ; break ; } case 'amalgamate' : { let accounts = get2Accounts ( ) ; op_payload = { 'dest_customer_id' : account_array [ accounts [ 0 ] ] , 'source_customer_id' : account_array [ accounts [ 1 ] ] , 'transaction_type' : random_op } ; break ; } default : { throw new Error ( 'Invalid operation!!!' ) ; } } workload . push ( op_payload ) ; } return workload ; }
Generates small bank workload with specified number of accounts
 and operations.
Generates small bank workload with specified number of accounts and operations .