Which method has better performance I want to update some term id on some node (let suppose 1000 node),My changes is convert all news node with category(term_id) = 3040 to category(term_id)=5).

I know I can do it with several methods( use views bulk operation, write batch running etc, .... ) but my question is about performance of below approaches


Approach based on old method ( node_save)

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
        -&gt;entityCondition('bundle', 'news')
        -&gt;propertyCondition('status', 1)
        -&gt;fieldCondition('field_category', 'tid', array('3040'));
$result = $query-&gt;execute();
$nids= array_keys($result['node']);
//ym($nids);

$nodes= node_load_multiple($nids);
foreach ($nodes as $node){
    foreach($node-&gt;field_category['und'] as $i=&gt;$item){
       if($item['tid']==3040){
            $node-&gt;field_category['und'][$i]['tid']=5;
            node_save($node);
        }
    }

}

Approach based on entity wrapper method

    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'node')
            -&gt;entityCondition('bundle', 'news')
            -&gt;propertyCondition('status', 1)
            -&gt;fieldCondition('field_category', 'tid', array('3040'));
    $result = $query-&gt;execute();
foreach($result['node'] as $nid =&gt; $stub_node) {
  // Load the full node and wrap it with entity_metadata_wrapper().
  $node = node_load($nid);
  $wrapped_node = entity_metadata_wrapper("node", $node);
  if ($wrapped_node-&gt;field_category-&gt;value()-&gt;tid == 3040) {
    $wrapped_node-&gt;field_category-&gt;tid-&gt;set(5);
    $wrapped_node-&gt;save();
  }



in first approach we have one node_load and one node_save but in second approach we have one node_load one creating entity metawrapper creation and one entity wrapper save.
I want to know which method has better performance?
let suppose we have the same situation for both 2 method, I just want somebody tell me ( take a benchmark on one node and  in bulk ( multi node) mode and tell me the performance of both that which one of this method is faster in the same situation.
please provide your answer with facts or benchmark testing result
This is essentially impossible to answer.  You have one part of your question, wrong


Your first method uses a single node_load_multiple() with multiple node_save
Your second answer uses multiple node_load() with multiple Entity API calls


My gut tells me the first will be quicker, as a single node_load_multiple() is typically more performant than multiple node_load() calls, given the same set of nodes.  You also aren't creating the the metadata wrapper objects.

However, you need to do the benchmarking on your system.  There may be a difference, but it may be small enough to not make a real imapact.  Some things that make cross-system benchmarks unreliable


entitycache can have a tremendous impact on a system, especially if you use a non-SQL backend for it
the number of fields on your node can effect how long the wrapper creation process takes, and also how long the node_save() takes
APC and/or OpCache usage and configuration
PHP version
MySQL configuration (or whatever database backend you are using), including some of the Drupal-specific tricks that can improve performance
The number of hook_node_update() instances that fire for each save