void RunBackend(oid_t thread_id) {
  auto txn_count = state.transaction_count;

  UniformGenerator generator;
  Timer<> timer;

  // Start timer
  timer.Reset();
  timer.Start();

  // Run these many transactions
  for (oid_t txn_itr = 0; txn_itr < txn_count; txn_itr++) {
    auto rng_val = generator.GetSample();

    if (rng_val <= 0.04) {
      RunStockLevel();
    } else if (rng_val <= 0.08) {
      RunDelivery();
    } else if (rng_val <= 0.12) {
      RunOrderStatus();
    } else if (rng_val <= 0.55) {
      RunPayment();
    } else {
      RunNewOrder();
    }

  }

  // Stop timer
  timer.Stop();

  // Set duration
  durations[thread_id] = timer.GetDuration();
}
Esempio n. 2
0
void RunBackend(oid_t thread_id) {

  UniformGenerator generator;

  oid_t &execution_count_ref = abort_counts[thread_id];
  oid_t &transaction_count_ref = commit_counts[thread_id];

  // Run these many transactions
  while (true) {
    if (is_running == false) {
      break;
    }
    auto rng_val = generator.GetSample();
    
    if (rng_val <= 0.04) {
      while (RunStockLevel() == false) {
        execution_count_ref++;
      }
    } else if (rng_val <= 0.08) {
      while (RunDelivery() == false) {
        execution_count_ref++;
      }
    } else if (rng_val <= 0.12) {
      while (RunOrderStatus() == false) {
        execution_count_ref++;
      }
    } else if (rng_val <= 0.55) {
      while (RunPayment() == false) {
        execution_count_ref++;
      }
    } else {
      while (RunNewOrder() == false) {
        execution_count_ref++;
      }
    }

    transaction_count_ref++;

  }
}