title: How to get real execution time when insert huge data to MySQL
body: <pre><code>console.time('timer');
  var mysql = require('mysql');
  var uniqid = require('uniqid');
  var moment = require('moment');
  
  var connection = mysql.createConnection({
      host     : 'localhost',
      user     : 'root',
      password : '',
      database : 'test'
  });
  connection.connect();
  
  var add = function() {
      var now = moment().format('YYYY-MM-DD hh:mm:ss');
  
      connection.query({
          sql: 'INSERT INTO `users` SET ?',
      }, {username: uniqid(), created_at: now}, function(err, rows, fields) {
          if (err) {
              console.log(err);
          }
      });
  };
  
  for (var i = 1; i &lt;= 5000; ++i) {
      add();
  }
  
  connection.end();
  console.timeEnd('timer');
  </code></pre>
  
  <p>I want to know to long the code take to insert 5000 datas to database, but the timer always show before real insert finished, how to fix it?</p>