dongzheng4556 2016-08-27 00:26
浏览 58
已采纳

Laravel:为什么数据库播种机在我的快速电脑上这么慢

I'm running a typical Laravel version 5.2.23 on Homestead Vagrant box on Win10 with a fast NVMe ssd, Skylake i7 6700K cpu, 16GB ram. VirtualBox 5.0.26 r108824. I have 4GB and 2 CPU's allocated to the VM. Pretty much everything is default.

This very basic user table seeder takes 45 seconds for 1000 records and I had faster performance with a much slower pc before with Laravel 4.2. When I hit the localhost site it loads fast with data ( I simply echo the entire 1000 record user table in index.html ) so it doesn't seem like a network traffic slowdown between the VM and Win10, but idk.

Seeder is below.

class UsersTableSeeder extends Seeder {

public function run() {
    DB::table('users')->truncate();

    for( $ii = 0; $ii < 1000; $ii++)
    DB::table('users')->insert([
        'name' => $ii,
        'email' => $ii.'@gmail.com',
        'password' => bcrypt('secret'),
    ]);


}

}

I know sometimes there can be weird Windows file system slowdowns with Linux based VM's, but I'm not sure whats going on here. Any help would be great.

  • 写回答

1条回答 默认 最新

  • doudou7361 2016-08-27 00:32
    关注

    Because bcrypt function call is slow. Usually it takes around 50ms for one operation(depending on machine it can be faster). (50ms * 1000op) / 1000ms = 50s.

    See more Why is php's password_hash so slow?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器