Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $start_time = microtime(true);
  2. foreach (range(1, 1000) as $id) {
  3. $node = Drupal::entityTypeManager()->getStorage('node')->load($id);
  4.  
  5. if ($node) {
  6. print_r($node->id());
  7. }
  8. }
  9. $end_time = microtime(true);
  10. $execution_time = ($end_time - $start_time);
  11. print_r($execution_time);
  12.  
  13. $start_time = microtime(true);
  14. $ids = [];
  15. foreach (range(1, 1000) as $id) {
  16. $ids[] = $id;
  17. }
  18.  
  19. $nodes = Drupal::entityTypeManager()->getStorage('node')->loadMultiple($ids);
  20.  
  21. foreach ($nodes as $node) {
  22. if ($node) {
  23. print_r($node->id());
  24. }
  25. }
  26. $end_time = microtime(true);
  27. $execution_time = ($end_time - $start_time);
  28. print_r($execution_time);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement