'field_map_storage_' . $i, 'entity_type' => 'contact_message', 'type' => 'text', ]); $storages[$i]->save(); } $start = microtime(TRUE); for ($i = 0; $i < 500; $i++) { $bundle_start = microtime(TRUE); $form = ContactForm::create([ 'id' => 'field_map_' . $i, 'label' => 'Contact form ' . $i, ]); $form->save(); $field_index = 0; foreach (array_rand($storages, 20) as $storage_key) { FieldConfig::create(array( 'field_storage' => $storages[$storage_key], 'label' => 'Field on ' . $form->label() . ' #' . $field_index++, 'bundle' => $form->id(), ))->save(); } print "$i: Created bundle with 20 fields in " . round(microtime(TRUE) - $bundle_start, 2) . "s\n"; } print "$i: Created 100 bundle with 20 fields each in " . round(microtime(TRUE) - $start, 2) . "s\n";