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?

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

报告相同问题?

悬赏问题

  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误