Skip to content

Instantly share code, notes, and snippets.

@fridzema
Created July 3, 2018 12:32
Show Gist options
  • Save fridzema/48e599eafebc72eeb26df878d12d0e73 to your computer and use it in GitHub Desktop.
Save fridzema/48e599eafebc72eeb26df878d12d0e73 to your computer and use it in GitHub Desktop.
public function handle()
{
$timings = [];
$results = [];
$loops = 10;
$bar = $this->output->createProgressBar($loops);
for($i = 1; $i <= $loops; $i++){
$start = microtime(true);
Contact::select('id')->get();
$timings[] = microtime(true) - $start;
$bar->advance();
}
$bar->finish();
$this->comment('');
$average = array_sum($timings) / count($timings);
$results[] = [
Cache::get('last_test_result'),
$average,
(Cache::has('last_test_result')) ? (Cache::get('last_test_result') - $average) : 0
];
$headers = ['last', 'current', 'difference'];
$this->table($headers, $results);
Cache::forever('last_test_result', $average);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment