38 lines
757 B
PHP
38 lines
757 B
PHP
<?php
|
|
|
|
namespace App\Tasks\PrimaryKey;
|
|
|
|
use App\Models\ProductBigInt;
|
|
use App\Models\Transaction;
|
|
|
|
class ProductsBigInt1Task
|
|
{
|
|
|
|
/**
|
|
* insert unit
|
|
*
|
|
* 100 ............ 0,021 s DONE
|
|
* 1_000 ............ 0,048 s DONE
|
|
* 10_000 ............ 0,285 s DONE
|
|
* 100_000 ........... 2,000 s DONE
|
|
* 1_000_000 ........... 3,000 s DONE
|
|
*
|
|
*/
|
|
public function handle(int $count): void
|
|
{
|
|
$block = 1000;
|
|
while ($count > 0) {
|
|
|
|
if ($count < $block) {
|
|
$block = $count;
|
|
}
|
|
|
|
$products = ProductBigInt::factory($block)->make();
|
|
ProductBigInt::query()->insert($products->toArray());
|
|
|
|
|
|
$count -= $block;
|
|
}
|
|
}
|
|
}
|